DATACMNS-1161 - Renamed PersistentProperty.getPersitentEntityType(…) to ….getPersitentEntityTypes(…).

The new name currently delegates to old version, so classes only implementing the old method still work. Old name is deprecated.

Original pull request: #243.
This commit is contained in:
Jens Schauder
2017-09-21 12:26:21 +02:00
committed by Oliver Gierke
parent 404610ebb4
commit ea03388a7c
5 changed files with 20 additions and 3 deletions

View File

@@ -30,6 +30,7 @@ import org.springframework.lang.Nullable;
* @author Jon Brisbin
* @author Oliver Gierke
* @author Mark Paluch
* @author Jens Schauder
*/
public interface PersistentProperty<P extends PersistentProperty<P>> {
@@ -61,6 +62,16 @@ public interface PersistentProperty<P extends PersistentProperty<P>> {
*/
TypeInformation<?> getTypeInformation();
/**
* Returns the {@link TypeInformation} if the property references a {@link PersistentEntity}. Will return
* {@literal null} in case it refers to a simple type. Will return {@link Collection}'s component type or the
* {@link Map}'s value type transparently.
*
* @Deprecated Use getPersistentEntityTypes instead.
*/
@Deprecated
Iterable<? extends TypeInformation<?>> getPersistentEntityType();
/**
* Returns the {@link TypeInformation} if the property references a {@link PersistentEntity}. Will return
* {@literal null} in case it refers to a simple type. Will return {@link Collection}'s component type or the
@@ -68,7 +79,9 @@ public interface PersistentProperty<P extends PersistentProperty<P>> {
*
* @return
*/
Iterable<? extends TypeInformation<?>> getPersistentEntityType();
default Iterable<? extends TypeInformation<?>> getPersistentEntityTypes() {
return getPersistentEntityType();
};
/**
* Returns the getter method to access the property value if available. Might return {@literal null} in case there is

View File

@@ -554,7 +554,7 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
return;
}
property.getPersistentEntityType().forEach(AbstractMappingContext.this::addPersistentEntity);
property.getPersistentEntityTypes().forEach(AbstractMappingContext.this::addPersistentEntity);
}
}

View File

@@ -133,6 +133,7 @@ public abstract class AbstractPersistentProperty<P extends PersistentProperty<P>
* (non-Javadoc)
* @see org.springframework.data.mapping.PersistentProperty#getPersistentEntityType()
*/
@Deprecated
@Override
public Iterable<? extends TypeInformation<?>> getPersistentEntityType() {

View File

@@ -113,7 +113,7 @@ public class AbstractMappingContextIntegrationTests<T extends PersistentProperty
when(prop.getTypeInformation()).thenReturn(owner.getTypeInformation());
when(prop.getName()).thenReturn(property.getName());
when(prop.getPersistentEntityType()).thenReturn(Collections.EMPTY_SET);
when(prop.getPersistentEntityTypes()).thenReturn(Collections.EMPTY_SET);
try {
Thread.sleep(200);

View File

@@ -44,6 +44,7 @@ import org.springframework.util.ReflectionUtils;
*
* @author Oliver Gierke
* @author Christoph Strobl
* @author Jens Schauder
*/
public class AbstractPersistentPropertyUnitTests {
@@ -66,6 +67,7 @@ public class AbstractPersistentPropertyUnitTests {
@Test // DATACMNS-101
public void returnsNestedEntityTypeCorrectly() {
assertThat(getProperty(TestClassComplex.class, "testClassSet").getPersistentEntityTypes()).isEmpty();
assertThat(getProperty(TestClassComplex.class, "testClassSet").getPersistentEntityType()).isEmpty();
}
@@ -189,6 +191,7 @@ public class AbstractPersistentPropertyUnitTests {
public void doesNotConsiderPropertyWithTreeMapMapValueAnEntity() {
SamplePersistentProperty property = getProperty(TreeMapWrapper.class, "map");
assertThat(property.getPersistentEntityTypes()).isEmpty();
assertThat(property.getPersistentEntityType()).isEmpty();
assertThat(property.isEntity()).isFalse();
}