MetricId implements Comparable<MetricId> { @Override public int hashCode() { return hash; } MetricId();  MetricId(String key);  MetricId(String key, Map<String, String> tags); @Deprecated @VisibleForTesting  MetricId(String key, SortedMap<String, String> tags); private  MetricId(String key, SortedMap<String, String> tags, boolean isAlreadyUnmodifiable); String getKey(); Map<String, String> getTags(); MetricId resolve(final String part); MetricId tagged(Map<String, String> add); MetricId tagged(String... pairs); MetricId tagged(String k1, String v1); MetricId tagged(String k1, String v1, String k2, String v2); MetricId tagged(String k1, String v1, String k2, String v2, String k3, String v3); static MetricId join(MetricId... parts); static MetricId build(final String... parts); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(MetricId o); static final String SEPARATOR; static final SortedMap<String, String> EMPTY_TAGS; static final MetricId EMPTY; }
@Test public void testEqualsAndHashCode() { final SortedMap<String, String> tags = new TreeMap<String, String>() { public boolean equals(Object o) { return false; } ; public int hashCode() { return 42; } ; }; final MetricId a = new MetricId(key, tags); final MetricId b = new MetricId(key, tags); assertEquals(a.hashCode(), b.hashCode()); assertNotEquals(a, b); }