Add equals methods for DistributedTraceId and TraceSegmentRef. Avoid duplication in TraceSegment, based on LinkedList.contains().
This commit is contained in:
parent
bca88fb1a1
commit
cd87d0d7cc
|
|
@ -23,4 +23,21 @@ public abstract class DistributedTraceId {
|
|||
public String get() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
DistributedTraceId id1 = (DistributedTraceId)o;
|
||||
|
||||
return id != null ? id.equals(id1.id) : id1.id == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id != null ? id.hashCode() : 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,21 +104,15 @@ public class TraceSegmentRef{
|
|||
|
||||
TraceSegmentRef ref = (TraceSegmentRef)o;
|
||||
|
||||
if (spanId != ref.spanId)
|
||||
return false;
|
||||
if (traceSegmentId != null ? !traceSegmentId.equals(ref.traceSegmentId) : ref.traceSegmentId != null)
|
||||
return false;
|
||||
if (applicationCode != null ? !applicationCode.equals(ref.applicationCode) : ref.applicationCode != null)
|
||||
return false;
|
||||
return peerHost != null ? peerHost.equals(ref.peerHost) : ref.peerHost == null;
|
||||
return applicationCode != null ? applicationCode.equals(ref.applicationCode) : ref.applicationCode == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = traceSegmentId != null ? traceSegmentId.hashCode() : 0;
|
||||
result = 31 * result + spanId;
|
||||
result = 31 * result + (applicationCode != null ? applicationCode.hashCode() : 0);
|
||||
result = 31 * result + (peerHost != null ? peerHost.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue