Interface MappingContext<E extends PersistentEntity<?,P> , P extends PersistentProperty<P>>
- All Known Implementing Classes:
AbstractMappingContext
public interface MappingContext<E extends PersistentEntity<?,P>, P extends PersistentProperty<P>>
This interface defines the overall context including all known PersistentEntity instances and methods to obtain
instances on demand. it is used internally to establish associations between entities and also at runtime to obtain
entities by name.
- Author:
- Oliver Gierke, Jon Brisbin, Graeme Rocher, Mark Paluch, Christoph Strobl, Johannes Englmeier
-
Method Summary
Modifier and TypeMethodDescription<T> PersistentPropertyPaths<T, P> findPersistentPropertyPaths(Class<T> type, Predicate<? super P> predicate) Returns allPersistentPropertyPaths pointing to properties on the given type that match the givenPredicate.Returns allPersistentEntitys held in the context.@Nullable EgetPersistentEntity(Class<?> type) Returns aPersistentEntityfor the givenClass.@Nullable EgetPersistentEntity(TypeInformation<?> type) Returns aPersistentEntityfor the givenTypeInformation.@Nullable EgetPersistentEntity(P persistentProperty) Returns thePersistentEntitymapped by the givenPersistentProperty.getPersistentPropertyPath(String propertyPath, Class<?> type) Returns allPersistentPropertys for the given dot path notation based on the given type.getPersistentPropertyPath(String propertyPath, TypeInformation<?> type) Returns allPersistentPropertys for the given dot path notation based on the given type.getPersistentPropertyPath(PropertyPath propertyPath) Returns allPersistentPropertys for the given path expression based on the givenPropertyPath.default EgetRequiredPersistentEntity(Class<?> type) Returns a requiredPersistentEntityfor the givenClass.default EReturns aPersistentEntityfor the givenTypeInformation.default EgetRequiredPersistentEntity(P persistentProperty) Returns thePersistentEntitymapped by the givenPersistentProperty.booleanhasPersistentEntityFor(Class<?> type) Returns whether theMappingContextcurrently contains aPersistentEntityfor the type.
-
Method Details
-
getPersistentEntities
Collection<E> getPersistentEntities()Returns allPersistentEntitys held in the context.- Returns:
- never null.
-
getPersistentEntity
Returns aPersistentEntityfor the givenClass. Will returnnullfor types that are considered simple ones.- Parameters:
type- must not be null.- Returns:
- null if no
PersistentEntityfound for type. - See Also:
-
getRequiredPersistentEntity
Returns a requiredPersistentEntityfor the givenClass. Will throwIllegalArgumentExceptionfor types that are considered simple ones.- Parameters:
type- must not be null.- Returns:
- never null.
- Throws:
MappingException- when noPersistentEntitycan be found for given type.- Since:
- 2.0
- See Also:
-
hasPersistentEntityFor
Returns whether theMappingContextcurrently contains aPersistentEntityfor the type.- Parameters:
type- must not be null.- Returns:
- true if
PersistentEntitypresent for given type. - Since:
- 1.8
-
getPersistentEntity
Returns aPersistentEntityfor the givenTypeInformation. Will returnnullfor types that are considered simple ones.- Parameters:
type- must not be null.- Returns:
- null if no
PersistentEntityfound forTypeInformation. - See Also:
-
getRequiredPersistentEntity
Returns aPersistentEntityfor the givenTypeInformation. Will throwIllegalArgumentExceptionfor types that are considered simple ones.- Parameters:
type- must not be null.- Returns:
- never null.
- Throws:
MappingException- when noPersistentEntitycan be found for givenTypeInformation.- See Also:
-
getPersistentEntity
Returns thePersistentEntitymapped by the givenPersistentProperty.- Parameters:
persistentProperty- must not be null.- Returns:
- the
PersistentEntitymapped by the givenPersistentPropertyor null if noPersistentEntityexists for it or thePersistentPropertydoes not refer to an entity (the type of the property is considered simple seeSimpleTypeHolder.isSimpleType(Class)).
-
getRequiredPersistentEntity
Returns thePersistentEntitymapped by the givenPersistentProperty.- Parameters:
persistentProperty- must not be null.- Returns:
- the
PersistentEntitymapped by the givenPersistentPropertyor null if noPersistentEntityexists for it or thePersistentPropertydoes not refer to an entity (the type of the property is considered simple seeSimpleTypeHolder.isSimpleType(Class)). - Throws:
MappingException- when noPersistentEntitycan be found for givenPersistentProperty.
-
getPersistentPropertyPath
PersistentPropertyPath<P> getPersistentPropertyPath(PropertyPath propertyPath) throws InvalidPersistentPropertyPath Returns allPersistentPropertys for the given path expression based on the givenPropertyPath.- Parameters:
propertyPath- must not be null.- Returns:
- the
PersistentPropertyPathrepresenting the givenPropertyPath. - Throws:
InvalidPersistentPropertyPath- in case not all segments of the givenPropertyPathcan be resolved.
-
getPersistentPropertyPath
PersistentPropertyPath<P> getPersistentPropertyPath(String propertyPath, Class<?> type) throws InvalidPersistentPropertyPath Returns allPersistentPropertys for the given dot path notation based on the given type.- Parameters:
propertyPath- must not be null.type- must not be null.- Returns:
- the
PersistentPropertyPathrepresenting the given property path on the given type. - Throws:
InvalidPersistentPropertyPath- in case not all segments of the given property path can be resolved.
-
getPersistentPropertyPath
PersistentPropertyPath<P> getPersistentPropertyPath(String propertyPath, TypeInformation<?> type) throws InvalidPersistentPropertyPath Returns allPersistentPropertys for the given dot path notation based on the given type.- Parameters:
propertyPath- must not be null.type- must not be null.- Returns:
- the
PersistentPropertyPathrepresenting 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
-
findPersistentPropertyPaths
<T> PersistentPropertyPaths<T,P> findPersistentPropertyPaths(Class<T> type, Predicate<? super P> predicate) Returns allPersistentPropertyPaths pointing to properties on the given type that match the givenPredicate. 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 a potentially expensive operation as results cannot be cached.- Parameters:
type- must not be null.predicate- must not be null.- Returns:
- Since:
- 2.1
-
getManagedTypes
Collection<TypeInformation<?>> getManagedTypes()- Returns:
- all
TypeInformations for thePersistentEntitys in theMappingContext. - Since:
- 1.8
-