toString, hashcode, equals

This commit is contained in:
renaudboutet 2017-04-27 15:42:19 +02:00
parent 348143967a
commit fd840abf26
2 changed files with 65 additions and 1 deletions

View File

@ -190,4 +190,34 @@ public class DDSpan implements io.opentracing.Span {
public List<Span> getTrace() { public List<Span> getTrace() {
return trace; return trace;
} }
@Override
public String toString() {
return context.toString();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((context == null) ? 0 : context.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
DDSpan other = (DDSpan) obj;
if (context == null) {
if (other.context != null)
return false;
} else if (!context.equals(other.context))
return false;
return true;
}
} }

View File

@ -110,4 +110,38 @@ public class DDSpanContext implements io.opentracing.SpanContext {
public Map<String, String> getBaggageItems() { public Map<String, String> getBaggageItems() {
return baggageItems; return baggageItems;
} }
@Override
public String toString() {
return "DDSpanContext [traceId=" + traceId
+ ", spanId=" + spanId
+ ", parentId=" + parentId +"]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (int) (spanId ^ (spanId >>> 32));
result = prime * result + (int) (traceId ^ (traceId >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
DDSpanContext other = (DDSpanContext) obj;
if (spanId != other.spanId)
return false;
if (traceId != other.traceId)
return false;
return true;
}
} }