TableEvent extends Event { @Override public int hashCode() { final int prime = 17; int result = super.hashCode(); result = prime * result + rowId + actionId.hashCode(); return result; } TableEvent(final String command, final int rowId, final String actionId); String getActionId(); int getRowId(); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test public void testHashCodeContract() { assertTrue("Wrong hashCode implementation, same objects have NOT same hash-code ", one.hashCode() == sameRefAsOne.hashCode()); assertFalse("Wrong hashCode implementation, different objects have same hash-code", one.hashCode() == two.hashCode()); assertTrue("Wrong hashCode implementation, same objects have NOT same hash-code ", one.hashCode() == sameAsOne.hashCode()); }