}
// Javadoc inherited.
public void testEqualsAndHashcodeImplementedCorrectly() {
MutableNumberSubTypeConstraint subTypeConstraint1 =
createMutableNumberSubTypeConstraint();
MutableNumberSubTypeConstraint subTypeConstraint2 =
createMutableNumberSubTypeConstraint();
// test that both the values are equal and they have the same hash codes
assertEquals("Object 1 should be equal to object 2", subTypeConstraint1,
subTypeConstraint2);
int subTypeConstraint1Hashcode = subTypeConstraint1.hashCode();
int subTypeConstraint2Hashcode = subTypeConstraint2.hashCode();
assertTrue("Objects which are equal should have the same hash codes. Were : "
+ subTypeConstraint1Hashcode + " and " + subTypeConstraint2Hashcode,
subTypeConstraint1Hashcode == subTypeConstraint2Hashcode);
subTypeConstraint2.setNumberSubType(Integer.class);
assertNotEquals(subTypeConstraint1, subTypeConstraint2);
assertNotEquals(subTypeConstraint2, subTypeConstraint1);
// ensure that the hashcodes are different for these two objects
subTypeConstraint1Hashcode = subTypeConstraint1.hashCode();
subTypeConstraint2Hashcode = subTypeConstraint2.hashCode();
assertFalse("Objects which are not equal should ideally have different hash codes",
subTypeConstraint1Hashcode == subTypeConstraint2Hashcode);
}