Refine customization of EntityInformation.
We now provide a getEntityInformation(RepositoryMetadata) customization hook for EntityInformation creation as several modules require access to RepositoryMetadata details (such as the Id type). Closes #3288
This commit is contained in:
@@ -261,7 +261,7 @@ public abstract class RepositoryFactoryBeanSupport<T extends Repository<S, ID>,
|
||||
@SuppressWarnings("unchecked")
|
||||
public EntityInformation<S, ID> getEntityInformation() {
|
||||
return (EntityInformation<S, ID>) getRequiredFactory()
|
||||
.getEntityInformation(getRequiredRepositoryMetadata().getDomainType());
|
||||
.getEntityInformation(getRequiredRepositoryMetadata());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -534,8 +534,23 @@ public abstract class RepositoryFactorySupport
|
||||
* @param <ID> the id type
|
||||
* @param domainClass
|
||||
* @return
|
||||
* @deprecated since 4.0, use {@link #getEntityInformation(RepositoryMetadata)} instead.
|
||||
*/
|
||||
public abstract <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass);
|
||||
@Deprecated(since = "4.0")
|
||||
public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
|
||||
throw new UnsupportedOperationException("getEntityInformation is not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link EntityInformation} for the given {@link RepositoryMetadata}.
|
||||
*
|
||||
* @param metadata must not be {@literal null}.
|
||||
* @return the {@link EntityInformation} to be used for {@link RepositoryMetadata}.
|
||||
* @since 4.0
|
||||
*/
|
||||
public EntityInformation<?, ?> getEntityInformation(RepositoryMetadata metadata) {
|
||||
return getEntityInformation(metadata.getDomainType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a repository instance as backing for the query proxy.
|
||||
|
||||
@@ -54,8 +54,7 @@ public class DummyReactiveRepositoryFactory extends ReactiveRepositoryFactorySup
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
|
||||
public EntityInformation<?, ?> getEntityInformation(RepositoryMetadata metadata) {
|
||||
return mock(EntityInformation.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,8 +77,7 @@ public class DummyRepositoryFactory extends RepositoryFactorySupport {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
|
||||
public EntityInformation<?, ?> getEntityInformation(RepositoryMetadata metadata) {
|
||||
return mock(EntityInformation.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,8 +77,7 @@ public class ReactiveDummyRepositoryFactory extends ReactiveRepositoryFactorySup
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
|
||||
public EntityInformation<?, ?> getEntityInformation(RepositoryMetadata metadata) {
|
||||
return mock(EntityInformation.class);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user