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
-
Method Summary
Modifier and TypeMethodDescription<T> PersistentPropertyPaths<T,
P> findPersistentPropertyPaths
(Class<T> type, Predicate<? super P> predicate) Returns allPersistentPropertyPath
s pointing to properties on the given type that match the givenPredicate
.Returns allPersistentEntity
s held in the context.getPersistentEntity
(Class<?> type) Returns aPersistentEntity
for the givenClass
.getPersistentEntity
(TypeInformation<?> type) Returns aPersistentEntity
for the givenTypeInformation
.getPersistentEntity
(P persistentProperty) Returns thePersistentEntity
mapped by the givenPersistentProperty
.getPersistentPropertyPath
(String propertyPath, Class<?> type) Returns allPersistentProperty
s for the given dot path notation based on the given type.getPersistentPropertyPath
(PropertyPath propertyPath) Returns allPersistentProperty
s for the given path expression based on the givenPropertyPath
.default E
getRequiredPersistentEntity
(Class<?> type) Returns a requiredPersistentEntity
for the givenClass
.default E
Returns aPersistentEntity
for the givenTypeInformation
.default E
getRequiredPersistentEntity
(P persistentProperty) Returns thePersistentEntity
mapped by the givenPersistentProperty
.boolean
hasPersistentEntityFor
(Class<?> type) Returns whether theMappingContext
currently contains aPersistentEntity
for the type.
-
Method Details
-
getPersistentEntities
Collection<E> getPersistentEntities()Returns allPersistentEntity
s held in the context.- Returns:
- never null.
-
getPersistentEntity
Returns aPersistentEntity
for the givenClass
. Will returnnull
for types that are considered simple ones.- Parameters:
type
- must not be null.- Returns:
- null if no
PersistentEntity
found for type. - See Also:
-
getRequiredPersistentEntity
Returns a requiredPersistentEntity
for the givenClass
. Will throwIllegalArgumentException
for types that are considered simple ones.- Parameters:
type
- must not be null.- Returns:
- never null.
- Throws:
MappingException
- when noPersistentEntity
can be found for given type.- Since:
- 2.0
- See Also:
-
hasPersistentEntityFor
Returns whether theMappingContext
currently contains aPersistentEntity
for the type.- Parameters:
type
- must not be null.- Returns:
- true if
PersistentEntity
present for given type. - Since:
- 1.8
-
getPersistentEntity
Returns aPersistentEntity
for the givenTypeInformation
. Will returnnull
for types that are considered simple ones.- Parameters:
type
- must not be null.- Returns:
- null if no
PersistentEntity
found forTypeInformation
. - See Also:
-
getRequiredPersistentEntity
Returns aPersistentEntity
for the givenTypeInformation
. Will throwIllegalArgumentException
for types that are considered simple ones.- Parameters:
type
- must not be null.- Returns:
- never null.
- Throws:
MappingException
- when noPersistentEntity
can be found for givenTypeInformation
.- See Also:
-
getPersistentEntity
Returns thePersistentEntity
mapped by the givenPersistentProperty
.- Parameters:
persistentProperty
- must not be null.- Returns:
- the
PersistentEntity
mapped by the givenPersistentProperty
or null if noPersistentEntity
exists for it or thePersistentProperty
does not refer to an entity (the type of the property is considered simple seeSimpleTypeHolder.isSimpleType(Class)
).
-
getRequiredPersistentEntity
Returns thePersistentEntity
mapped by the givenPersistentProperty
.- Parameters:
persistentProperty
- must not be null.- Returns:
- the
PersistentEntity
mapped by the givenPersistentProperty
or null if noPersistentEntity
exists for it or thePersistentProperty
does not refer to an entity (the type of the property is considered simple seeSimpleTypeHolder.isSimpleType(Class)
). - Throws:
MappingException
- when noPersistentEntity
can be found for givenPersistentProperty
.
-
getPersistentPropertyPath
PersistentPropertyPath<P> getPersistentPropertyPath(PropertyPath propertyPath) throws InvalidPersistentPropertyPath Returns allPersistentProperty
s for the given path expression based on the givenPropertyPath
.- Parameters:
propertyPath
- must not be null.- Returns:
- the
PersistentPropertyPath
representing the givenPropertyPath
. - Throws:
InvalidPersistentPropertyPath
- in case not all of the segments of the givenPropertyPath
can be resolved.
-
getPersistentPropertyPath
PersistentPropertyPath<P> getPersistentPropertyPath(String propertyPath, Class<?> type) throws InvalidPersistentPropertyPath Returns allPersistentProperty
s for the given dot path notation based on the given type.- Parameters:
propertyPath
- must not be null.type
- must not be null.- Returns:
- the
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.
-
findPersistentPropertyPaths
<T> PersistentPropertyPaths<T,P> findPersistentPropertyPaths(Class<T> type, Predicate<? super P> predicate) Returns allPersistentPropertyPath
s 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 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
TypeInformation
s for thePersistentEntity
s in theMappingContext
. - Since:
- 1.8
-