Class AbstractMappingContext<E extends MutablePersistentEntity<?,P>,P extends PersistentProperty<P>>  
java.lang.Object
org.springframework.data.mapping.context.AbstractMappingContext<E,P> 
- Type Parameters:
- E- the concrete- PersistentEntitytype the- MappingContextimplementation creates
- P- the concrete- PersistentPropertytype the- MappingContextimplementation creates
- All Implemented Interfaces:
- Aware,- InitializingBean,- ApplicationContextAware,- ApplicationEventPublisherAware,- MappingContext<E,- P> 
public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?,P>,P extends PersistentProperty<P>>  
extends Object
implements MappingContext<E,P>, ApplicationEventPublisherAware, ApplicationContextAware, InitializingBean 
Base class to build mapping metadata and thus create instances of 
PersistentEntity and
 PersistentProperty.
 
 The implementation uses a ReentrantReadWriteLock to make sure PersistentEntity are completely
 populated before accessing them from outside.
- Author:
- Jon Brisbin, Oliver Gierke, Michael Hunger, Thomas Darimont, Tomasz Wysocki, Mark Paluch, Mikael Klamra, Christoph Strobl
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionaddPersistentEntity(Class<?> type) Adds the given type to theMappingContext.addPersistentEntity(TypeInformation<?> typeInformation) Adds the givenTypeInformationto theMappingContext.voidprotected abstract <T> EcreatePersistentEntity(TypeInformation<T> typeInformation) Creates the concretePersistentEntityinstance.protected abstract PcreatePersistentProperty(Property property, E owner, SimpleTypeHolder simpleTypeHolder) Creates the concrete instance ofPersistentProperty.protected final <T> PersistentPropertyPaths<T,P> doFindPersistentPropertyPaths(Class<T> type, Predicate<? super P> predicate, Predicate<P> traversalGuard) Actually looks up thePersistentPropertyPathsfor the given type, selection predicate and traversal guard.<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.getPersistentEntity(Class<?> type) Returns aPersistentEntityfor the givenClass.getPersistentEntity(TypeInformation<?> type) Returns aPersistentEntityfor the givenTypeInformation.getPersistentEntity(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(PropertyPath propertyPath) Returns allPersistentPropertys for the given path expression based on the givenPropertyPath.booleanhasPersistentEntityFor(Class<?> type) Returns whether theMappingContextcurrently contains aPersistentEntityfor the type.voidInitializes the mapping context.voidsetApplicationContext(ApplicationContext applicationContext) voidsetApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) voidsetInitialEntitySet(Set<? extends Class<?>> initialEntitySet) Sets theSetof types to populate the context initially.voidsetManagedTypes(ManagedTypes managedTypes) Sets the types to populate the context initially.voidsetSimpleTypeHolder(SimpleTypeHolder simpleTypes) Configures theSimpleTypeHolderto be used by theMappingContext.voidsetStrict(boolean strict) Configures whether theMappingContextis in strict mode which means, that it will throwMappingExceptions in case one tries to lookup aPersistentEntitynot already in the context.protected booleanReturns whether aPersistentEntityinstance should be created for the givenTypeInformation.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.data.mapping.context.MappingContextgetRequiredPersistentEntity, getRequiredPersistentEntity, getRequiredPersistentEntity
- 
Constructor Details- 
AbstractMappingContextprotected AbstractMappingContext()
 
- 
- 
Method Details- 
setApplicationEventPublisher- Specified by:
- setApplicationEventPublisherin interface- ApplicationEventPublisherAware
 
- 
setApplicationContext- Specified by:
- setApplicationContextin interface- ApplicationContextAware
- Throws:
- BeansException
 
- 
setInitialEntitySetSets theSetof types to populate the context initially.- Parameters:
- initialEntitySet-
- See Also:
 
- 
setManagedTypesSets the types to populate the context initially.- Parameters:
- managedTypes- must not be null. Use- ManagedTypes.empty()instead.
- Since:
- 3.0
 
- 
setStrictpublic void setStrict(boolean strict) Configures whether theMappingContextis in strict mode which means, that it will throwMappingExceptions in case one tries to lookup aPersistentEntitynot already in the context. This defaults to false so that unknown types will be transparently added to the MappingContext if not known in advance.- Parameters:
- strict-
 
- 
setSimpleTypeHolderConfigures theSimpleTypeHolderto be used by theMappingContext. Allows customization of what types will be regarded as simple types and thus not recursively analyzed.- Parameters:
- simpleTypes- must not be null.
 
- 
getPersistentEntitiesDescription copied from interface:MappingContextReturns allPersistentEntitys held in the context.- Specified by:
- getPersistentEntitiesin interface- MappingContext<E extends MutablePersistentEntity<?,- P>, - P extends PersistentProperty<P>> 
- Returns:
- never null.
 
- 
getPersistentEntityDescription copied from interface:MappingContextReturns aPersistentEntityfor the givenClass. Will returnnullfor types that are considered simple ones.- Specified by:
- getPersistentEntityin interface- MappingContext<E extends MutablePersistentEntity<?,- P>, - P extends PersistentProperty<P>> 
- Parameters:
- type- must not be null.
- Returns:
- null if no PersistentEntityfound for type.
- See Also:
 
- 
hasPersistentEntityForDescription copied from interface:MappingContextReturns whether theMappingContextcurrently contains aPersistentEntityfor the type.- Specified by:
- hasPersistentEntityForin interface- MappingContext<E extends MutablePersistentEntity<?,- P>, - P extends PersistentProperty<P>> 
- Parameters:
- type- must not be null.
- Returns:
- true if PersistentEntitypresent for given type.
 
- 
getPersistentEntityDescription copied from interface:MappingContextReturns aPersistentEntityfor the givenTypeInformation. Will returnnullfor types that are considered simple ones.- Specified by:
- getPersistentEntityin interface- MappingContext<E extends MutablePersistentEntity<?,- P>, - P extends PersistentProperty<P>> 
- Parameters:
- type- must not be null.
- Returns:
- null if no PersistentEntityfound forTypeInformation.
- See Also:
 
- 
getPersistentEntityDescription copied from interface:MappingContextReturns thePersistentEntitymapped by the givenPersistentProperty.- Specified by:
- getPersistentEntityin interface- MappingContext<E extends MutablePersistentEntity<?,- P>, - P extends PersistentProperty<P>> 
- 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)).
 
- 
getPersistentPropertyPathDescription copied from interface:MappingContextReturns allPersistentPropertys for the given path expression based on the givenPropertyPath.- Specified by:
- getPersistentPropertyPathin interface- MappingContext<E extends MutablePersistentEntity<?,- P>, - P extends PersistentProperty<P>> 
- Parameters:
- propertyPath- must not be null.
- Returns:
- the PersistentPropertyPathrepresenting the givenPropertyPath.
 
- 
getPersistentPropertyPathDescription copied from interface:MappingContextReturns allPersistentPropertys for the given dot path notation based on the given type.- Specified by:
- getPersistentPropertyPathin interface- MappingContext<E extends MutablePersistentEntity<?,- P>, - P extends PersistentProperty<P>> 
- Parameters:
- propertyPath- must not be null.
- type- must not be null.
- Returns:
- the PersistentPropertyPathrepresenting the given property path on the given type.
 
- 
findPersistentPropertyPathspublic <T> PersistentPropertyPaths<T,P> findPersistentPropertyPaths(Class<T> type, Predicate<? super P> predicate) Description copied from interface:MappingContextReturns 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 is a potentially expensive operation as results cannot be cached.- Specified by:
- findPersistentPropertyPathsin interface- MappingContext<E extends MutablePersistentEntity<?,- P>, - P extends PersistentProperty<P>> 
- Parameters:
- type- must not be null.
- predicate- must not be null.
- Returns:
 
- 
doFindPersistentPropertyPathsprotected final <T> PersistentPropertyPaths<T,P> doFindPersistentPropertyPaths(Class<T> type, Predicate<? super P> predicate, Predicate<P> traversalGuard) Actually looks up thePersistentPropertyPathsfor the given type, selection predicate and traversal guard. Primary purpose is to allow sub-types to alter the default traversal guard, e.g. used byfindPersistentPropertyPaths(Class, Predicate).- Parameters:
- type- will never be null.
- predicate- will never be null.
- traversalGuard- will never be null.
- Returns:
- will never be null.
- See Also:
 
- 
addPersistentEntityAdds the given type to theMappingContext.- Parameters:
- type- must not be null.
- Returns:
 
- 
addPersistentEntityAdds the givenTypeInformationto theMappingContext.- Parameters:
- typeInformation- must not be null.
- Returns:
 
- 
getManagedTypesDescription copied from interface:MappingContext- Specified by:
- getManagedTypesin interface- MappingContext<E extends MutablePersistentEntity<?,- P>, - P extends PersistentProperty<P>> 
- Returns:
- all TypeInformations for thePersistentEntitys in theMappingContext.
 
- 
createPersistentEntityCreates the concretePersistentEntityinstance.- Type Parameters:
- T-
- Parameters:
- typeInformation-
- Returns:
 
- 
createPersistentPropertyprotected abstract P createPersistentProperty(Property property, E owner, SimpleTypeHolder simpleTypeHolder) Creates the concrete instance ofPersistentProperty.- Parameters:
- property-
- owner-
- simpleTypeHolder-
- Returns:
 
- 
afterPropertiesSetpublic void afterPropertiesSet()- Specified by:
- afterPropertiesSetin interface- InitializingBean
 
- 
initializepublic void initialize()Initializes the mapping context. Will add the types configured throughsetInitialEntitySet(Set)to the context.
- 
shouldCreatePersistentEntityForReturns whether aPersistentEntityinstance should be created for the givenTypeInformation. By default this will reject all types considered simple and non-supported Kotlin classes, but it might be necessary to tweak that in case you have registered custom converters for top level types (which renders them to be considered simple) but still need meta-information about them.- Parameters:
- type- will never be null.
- Returns:
 
 
-