提交 cd87d0d7 编写于 作者: wu-sheng's avatar wu-sheng

Add equals methods for DistributedTraceId and TraceSegmentRef. Avoid...

Add equals methods for DistributedTraceId and TraceSegmentRef. Avoid duplication in TraceSegment, based on LinkedList.contains().
上级 bca88fb1
......@@ -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;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册