HardcodedFilter extends AbstractFilter { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; HardcodedFilter that = (HardcodedFilter) o; if (filter != null ? !filter.equals(that.filter) : that.filter != null) return false; return true; } HardcodedFilter(String filter); StringBuffer encode(StringBuffer buff); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testEquals() { String attribute = "(foo=a*b)"; HardcodedFilter originalObject = new HardcodedFilter(attribute); HardcodedFilter identicalObject = new HardcodedFilter(attribute); HardcodedFilter differentObject = new HardcodedFilter("(bar=a*b)"); HardcodedFilter subclassObject = new HardcodedFilter(attribute) { }; new EqualsTester(originalObject, identicalObject, differentObject, subclassObject); }