SmallTagMap implements Iterable<Tag> { @Override public int hashCode() { if (cachedHashCode == 0) { cachedHashCode = Arrays.hashCode(tagArray); } return cachedHashCode; } SmallTagMap(Tag[] tagArray); static Builder builder(); @Override Iterator<Tag> iterator(); Tag get(String key); @Override int hashCode(); @Override String toString(); boolean containsKey(String k); boolean isEmpty(); int size(); @Deprecated Set<Tag> tagSet(); @Override /** {@inheritDoc} */ boolean equals(Object obj); static final int MAX_TAGS; static final int INITIAL_TAG_SIZE; }
@Test public void testHashcode() { SmallTagMap map1 = SmallTagMap.builder().add(Tags.newTag("k1", "v1")).result(); SmallTagMap map2 = SmallTagMap.builder().add(Tags.newTag("k1", "v2")).result(); SmallTagMap map3 = SmallTagMap.builder().add(Tags.newTag("k1", "v1")).result(); assertEquals(map1.hashCode(), map1.hashCode()); assertEquals(map1.hashCode(), map3.hashCode()); assertNotEquals(map1.hashCode(), map2.hashCode()); }