Allow reuse of TypeInformation when obtaining a PersistentPropertyPath.

Closes #2992
This commit is contained in:
Mark Paluch
2023-11-29 09:17:13 +01:00
parent 0ee6c04e54
commit 49f2af2b2f
2 changed files with 21 additions and 7 deletions

View File

@@ -33,7 +33,6 @@ import java.util.stream.Collectors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
@@ -304,6 +303,11 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
return persistentPropertyPathFactory.from(type, propertyPath);
}
@Override
public PersistentPropertyPath<P> getPersistentPropertyPath(String propertyPath, TypeInformation<?> type) {
return persistentPropertyPathFactory.from(type, propertyPath);
}
@Override
public <T> PersistentPropertyPaths<T, P> findPersistentPropertyPaths(Class<T> type, Predicate<? super P> predicate) {
@@ -315,7 +319,7 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
/**
* Actually looks up the {@link PersistentPropertyPaths} for the given type, selection predicate and traversal guard.
* Primary purpose is to allow sub-types to alter the default traversal guard, e.g. used by
* Primary purpose is to allow subtypes to alter the default traversal guard, e.g. used by
* {@link #findPersistentPropertyPaths(Class, Predicate)}.
*
* @param type will never be {@literal null}.

View File

@@ -158,8 +158,7 @@ public interface MappingContext<E extends PersistentEntity<?, P>, P extends Pers
*
* @param propertyPath must not be {@literal null}.
* @return the {@link PersistentPropertyPath} representing the given {@link PropertyPath}.
* @throws InvalidPersistentPropertyPath in case not all of the segments of the given {@link PropertyPath} can be
* resolved.
* @throws InvalidPersistentPropertyPath in case not all segments of the given {@link PropertyPath} can be resolved.
*/
PersistentPropertyPath<P> getPersistentPropertyPath(PropertyPath propertyPath) throws InvalidPersistentPropertyPath;
@@ -169,16 +168,27 @@ public interface MappingContext<E extends PersistentEntity<?, P>, P extends Pers
* @param propertyPath must not be {@literal null}.
* @param type must not be {@literal null}.
* @return the {@link PersistentPropertyPath} representing the given property path on the given type.
* @throws InvalidPersistentPropertyPath in case not all of the segments of the given property path can be resolved.
* @throws InvalidPersistentPropertyPath in case not all segments of the given property path can be resolved.
*/
PersistentPropertyPath<P> getPersistentPropertyPath(String propertyPath, Class<?> type)
throws InvalidPersistentPropertyPath;
/**
* Returns all {@link PersistentProperty}s for the given dot path notation based on the given type.
*
* @param propertyPath must not be {@literal null}.
* @param type must not be {@literal null}.
* @return the {@link PersistentPropertyPath} representing the given property path on the given type.
* @throws InvalidPersistentPropertyPath in case not all segments of the given property path can be resolved.
* @since 3.2.1
*/
PersistentPropertyPath<P> getPersistentPropertyPath(String propertyPath, TypeInformation<?> type)
throws InvalidPersistentPropertyPath;
/**
* Returns all {@link PersistentPropertyPath}s pointing to properties on the given type that match the given
* {@link Predicate}. In case of circular references the detection will stop at the property that references a type
* that's already included in the path. Note, that is is a potentially expensive operation as results cannot be
* cached.
* that's already included in the path. Note, that is a potentially expensive operation as results cannot be cached.
*
* @param type must not be {@literal null}.
* @param predicate must not be {@literal null}.