Metric implements Serializable { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Metric metric = (Metric) o; if (name != null ? !name.equals(metric.name) : metric.name != null) return false; if (tags != null) { if (tags.size() != metric.tags.size()) { return false; } else if (!tags.containsAll(metric.tags)) { return false; } } return value != null ? value.equals(metric.value) : metric.value == null; } Metric();  Metric(Metric other);  Metric(String name, long timestamp, double measure);  Metric(String name, long timestamp, double measure, List<Tag> tags);  Metric(String name, List<Tag> tags); static Builder newBuilder(); @JsonGetter("name") String getName(); void setName(String name); @JsonGetter("tags") List<Tag> getTags(); void setTags(List<Tag> tags); void addTag(Tag tag); @JsonUnwrapped Value getValue(); void setValue(Value value); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testEquals() { Metric m1 = Metric.newBuilder().name("m1").tag("t1", "v1").tag("t2", "v2").value(1, 0.0).build(); Metric m2 = Metric.newBuilder().name("m1").tag("t2", "v2").tag("t1", "v1").value(1, 0.0).build(); assertTrue(m1.equals(m2)); assertTrue(m2.equals(m1)); Metric m3 = Metric.newBuilder().name("m1").tag("t1", "v1").value(1, 0.0).build(); assertFalse(m1.equals(m3)); Metric m4 = Metric.newBuilder().name("m4").tag("t2", "v2").tag("t1", "v1").value(1, 0.0).build(); assertFalse(m1.equals(m4)); Metric m5 = Metric.newBuilder().name("m1").tag("t3", "v3").tag("t2", "v2").tag("t1", "v1").value(1, 0.0) .build(); assertFalse(m1.equals(m5)); Metric m6 = Metric.newBuilder().name("m1").tag("t2", "v2").tag("t1", "v1").value(2, 0.0).build(); assertFalse(m1.equals(m6)); Metric m7 = Metric.newBuilder().name("m1").tag("t2", "v2").tag("t1", "v1").value(1, 1.0).build(); assertFalse(m1.equals(m7)); }