TableMultiSelectEvent extends Event { @Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } TableMultiSelectEvent other = (TableMultiSelectEvent) obj; if (other.getCommand() == null && getCommand() != null) { return false; } else if (other.getCommand() != null && getCommand() == null) { return false; } boolean isSame = other.action.equals(action); isSame = isSame && other.selection.equals(selection); isSame = isSame && other.getCommand().equals(getCommand()); return isSame; } TableMultiSelectEvent(final String command, final String action, final BitSet selection); String getAction(); BitSet getSelection(); @Override boolean equals(final Object obj); @Override int hashCode();  }
@Test public void testEqualsCodeContract() { assertFalse("Wrong equals implementation, different types are recognized as equals ", one.equals(new Integer(1))); assertFalse("Wrong equals implementation, different objects are recognized as equals ", one.equals(two)); assertFalse("Wrong equals implementation, null value is recognized as equals ", one.equals(null)); assertTrue("Wrong equals implementation, same objects are NOT recognized as equals ", one.equals(sameRefAsOne)); assertTrue("Wrong equals implementation, same objecst are NOT recognized as equals ", one.equals(sameAsOne)); }