Tag implements Serializable { @Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (!(obj instanceof Tag)) { return false; } Tag other = (Tag) obj; if (this.key == null && other.key != null) { return false; } else if (this.key != null && !this.key.equals(other.key)) { return false; } else if (this.value == null && other.value != null) { return false; } else if (this.value != null && !this.value.equals(other.value)) { return false; } return true; } Tag(String tag);  Tag(String key, String value); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); final String key; final String value; }
@Test public void equalsTest() { Tag tag1 = new Tag(KEY, VALUE); Tag tag2 = new Tag(KEY, VALUE); Tag tag3 = new Tag(KEY, KEY); TestUtils.equalsTest(tag1, tag2); Assert.assertFalse(tag1.equals(tag3)); Assert.assertFalse(tag3.equals(tag1)); Assert.assertFalse(tag1.equals(new Object())); }