Tag { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Tag other = (Tag) obj; return text.equals(other.text); } Tag(int line, String text); int getLine(); String getText(); String getName(); List<String> getValues(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testEquals() { assertTrue(tag.equals(tag)); assertFalse(tag.equals(null)); assertFalse(tag.equals(new Tag(0, "@baz=bar,foo"))); assertFalse(tag.equals("foo")); }