Skip to content

Commit

Permalink
Implements equals method
Browse files Browse the repository at this point in the history
  • Loading branch information
quaff committed Sep 14, 2020
1 parent 469cf22 commit 1f148dc
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -621,4 +621,19 @@ public <T> T getObject(int parameterIndex, Class<T> type) throws SQLException {
public <T> T getObject(String parameterName, Class<T> type) throws SQLException {
return statement.getObject(parameterName, type);
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof CallableStatement)) {
return false;
}
if (obj instanceof TracingCallableStatement) {
return statement.equals(((TracingCallableStatement) obj).statement);
} else {
return statement.equals(obj);
}
}
}
16 changes: 16 additions & 0 deletions src/main/java/io/opentracing/contrib/jdbc/TracingConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,20 @@ public <T> T unwrap(Class<T> iface) throws SQLException {
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return connection.isWrapperFor(iface);
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Connection)) {
return false;
}
if (obj instanceof TracingConnection) {
return connection.equals(((TracingConnection) obj).connection);
} else {
return connection.equals(obj);
}
}

}
15 changes: 15 additions & 0 deletions src/main/java/io/opentracing/contrib/jdbc/TracingDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,21 @@ public boolean isWrapperFor(final Class<?> iface) throws SQLException {
return underlying.isWrapperFor(iface);
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof DataSource)) {
return false;
}
if (obj instanceof TracingDataSource) {
return underlying.equals(((TracingDataSource) obj).underlying);
} else {
return underlying.equals(obj);
}
}

@Override
public void close() throws Exception {
if (underlying instanceof AutoCloseable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,4 +362,19 @@ public void setNClob(int parameterIndex, Reader reader) throws SQLException {
preparedStatement.setNClob(parameterIndex, reader);
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof PreparedStatement)) {
return false;
}
if (obj instanceof TracingPreparedStatement) {
return preparedStatement.equals(((TracingPreparedStatement) obj).preparedStatement);
} else {
return preparedStatement.equals(obj);
}
}

}
16 changes: 16 additions & 0 deletions src/main/java/io/opentracing/contrib/jdbc/TracingStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.opentracing.Scope;
import io.opentracing.Span;
import io.opentracing.Tracer;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
Expand Down Expand Up @@ -372,6 +373,21 @@ public String toString() {
return getQuery();
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Statement)) {
return false;
}
if (obj instanceof TracingStatement) {
return statement.equals(((TracingStatement) obj).statement);
} else {
return statement.equals(obj);
}
}

private Span buildSpanForBatch() {
StringBuilder sqlBuilder = new StringBuilder();
if (query != null) {
Expand Down

0 comments on commit 1f148dc

Please sign in to comment.