SmallTagMap implements Iterable<Tag> { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || !(obj instanceof SmallTagMap)) { return false; } SmallTagMap that = (SmallTagMap) obj; return Arrays.equals(tagArray, that.tagArray); } 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; }
@SuppressWarnings({"EqualsWithItself", "ObjectEqualsNull"}) @Test public void testEquals() { 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(); SmallTagMap map4 = SmallTagMap.builder().add(Tags.newTag("k1", "v1")) .add(Tags.newTag("k2", "v2")).result(); assertTrue(map1.equals(map1)); assertTrue(map1.equals(map3)); assertFalse(map1.equals(map2)); assertFalse(map1.equals(null)); assertFalse(map1.equals(map4)); }