return new ImmutableChoiceTypeImpl();
}
// Javadoc inherited.
public void testEqualsAndHashcodeImplementedCorrectly() {
MutableChoiceType choiceType1 = createChoiceTypeForTests();
MutableChoiceType choiceType2 = createChoiceTypeForTests();
// ensure that the two objects are equal
assertEquals("Object 1 should be equal to object 2",
choiceType1, choiceType2);
// ensure that they have the same hash code
int ChoiceType1Hashcode = choiceType1.hashCode();
int ChoiceType2Hashcode = choiceType2.hashCode();
assertTrue("Objects which are equal should have the same hash codes. Were : "
+ ChoiceType1Hashcode + " and " + ChoiceType2Hashcode,
ChoiceType1Hashcode == ChoiceType2Hashcode);
// now change a single item in each list and ensure that they are different
MutableChoiceDefinitionImpl choiceDefinition = new MutableChoiceDefinitionImpl();
choiceDefinition.setType( new MutableBooleanTypeImpl() );
choiceType2.getMutableChoiceDefinitions().add(choiceDefinition);
assertNotEquals(choiceType1, choiceType2);
// see if the hashcodes are different
ChoiceType1Hashcode = choiceType1.hashCode();
ChoiceType2Hashcode = choiceType2.hashCode();
assertFalse("Objects which are not equal should ideally not have the same hash " +
"codes. Were : " + ChoiceType1Hashcode + " and "
+ ChoiceType2Hashcode,
ChoiceType1Hashcode == ChoiceType2Hashcode);
}