DATACMNS-121 - Implement equals(…) and hashCode() of AbstractPersistentProperty.

Implemented equals(…) and hashCode() methods based on the field backing the property.
This commit is contained in:
Oliver Gierke
2012-04-11 21:00:03 +02:00
parent f3d037ba7d
commit aa12db22c0
2 changed files with 56 additions and 0 deletions

View File

@@ -78,6 +78,34 @@ public class AbstractPersistentPropertyUnitTests {
assertThat(property.isEntity(), is(false));
}
/**
* @see DATACMNS-121
*/
@Test
public void considersPropertiesEqualIfFieldEquals() {
Field first = ReflectionUtils.findField(FirstConcrete.class, "genericField");
Field second = ReflectionUtils.findField(SecondConcrete.class, "genericField");
SamplePersistentProperty firstProperty = new SamplePersistentProperty(first, null, entity, typeHolder);
SamplePersistentProperty secondProperty = new SamplePersistentProperty(second, null, entity, typeHolder);
assertThat(firstProperty, is(secondProperty));
assertThat(firstProperty.hashCode(), is(secondProperty.hashCode()));
}
class Generic<T> {
T genericField;
}
class FirstConcrete extends Generic<String> {
}
class SecondConcrete extends Generic<Integer> {
}
@SuppressWarnings("serial")
class TestClassSet extends TreeSet<Object> {
}