Class MongoPersistentEntityIndexResolver
java.lang.Object
org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver
- All Implemented Interfaces:
IndexResolver
IndexResolver implementation inspecting MongoPersistentEntity for MongoPersistentEntity to be
indexed. All
MongoPersistentProperty of the MongoPersistentEntity are inspected for potential indexes by
scanning related annotations.- Since:
- 1.5
- Author:
- Christoph Strobl, Thomas Darimont, Martin Macko, Mark Paluch, Dave Perryman, Stefan Tirea, Sangbeen Moon
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classImplementation ofIndexDefinitionholding additional (property)path information used for creating the index. -
Constructor Summary
ConstructorsConstructorDescriptionMongoPersistentEntityIndexResolver(MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext) Create newMongoPersistentEntityIndexResolver. -
Method Summary
Modifier and TypeMethodDescriptioncreateCompoundIndexDefinition(String dotPath, String collection, CompoundIndex index, MongoPersistentEntity<?> entity) createCompoundIndexDefinitions(String dotPath, String fallbackCollection, MongoPersistentEntity<?> entity) CreateIndexDefinitionwrapped inMongoPersistentEntityIndexResolver.IndexDefinitionHolderforCompoundIndexesof a given type.protected @Nullable MongoPersistentEntityIndexResolver.IndexDefinitionHoldercreateGeoSpatialIndexDefinition(String dotPath, String collection, MongoPersistentProperty persistentProperty) CreatesIndexDefinitionwrapped inMongoPersistentEntityIndexResolver.IndexDefinitionHolderout ofGeoSpatialIndexedforMongoPersistentProperty.protected @Nullable MongoPersistentEntityIndexResolver.IndexDefinitionHoldercreateHashedIndexDefinition(String dotPath, String collection, MongoPersistentProperty persistentProperty) CreatesHashedIndexwrapped inMongoPersistentEntityIndexResolver.IndexDefinitionHolderout ofHashIndexedfor a givenMongoPersistentProperty.protected @Nullable MongoPersistentEntityIndexResolver.IndexDefinitionHoldercreateIndexDefinition(String dotPath, String collection, MongoPersistentProperty persistentProperty) CreatesIndexDefinitionwrapped inMongoPersistentEntityIndexResolver.IndexDefinitionHolderout ofIndexedfor a givenMongoPersistentProperty.createWildcardIndexDefinition(String dotPath, String collection, WildcardIndexed index, @Nullable MongoPersistentEntity<?> entity) protected EvaluationContextGet the defaultEvaluationContext.resolveIndexFor(TypeInformation<?> typeInformation) Find and createIndexDefinitions for properties of givenTypeInformation.Resolve theIndexDefinitions for a given root entity by traversingMongoPersistentPropertyscanning for index annotationsIndexed,CompoundIndexandGeospatialIndex.voidsetEvaluationContextProvider(EvaluationContextProvider evaluationContextProvider) Set theEvaluationContextProviderused for obtaining theEvaluationContextused to computeexpressions.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface IndexResolver
resolveIndexFor
-
Constructor Details
-
MongoPersistentEntityIndexResolver
public MongoPersistentEntityIndexResolver(MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext) Create newMongoPersistentEntityIndexResolver.- Parameters:
mappingContext- must not be null.
-
-
Method Details
-
resolveIndexFor
public Iterable<? extends MongoPersistentEntityIndexResolver.IndexDefinitionHolder> resolveIndexFor(TypeInformation<?> typeInformation) Description copied from interface:IndexResolverFind and createIndexDefinitions for properties of givenTypeInformation.IndexDefinitions are created for properties and types withIndexed,CompoundIndexesorGeoSpatialIndexed.- Specified by:
resolveIndexForin interfaceIndexResolver- Parameters:
typeInformation- must not be null.- Returns:
- Empty
Iterablein case noIndexDefinitioncould be resolved for type.
-
resolveIndexForEntity
public List<MongoPersistentEntityIndexResolver.IndexDefinitionHolder> resolveIndexForEntity(MongoPersistentEntity<?> root) Resolve theIndexDefinitions for a given root entity by traversingMongoPersistentPropertyscanning for index annotationsIndexed,CompoundIndexandGeospatialIndex. The given root has therefore to be annotated withDocument.- Parameters:
root- must not be null.- Returns:
- List of
MongoPersistentEntityIndexResolver.IndexDefinitionHolder. Will never be null. - Throws:
IllegalArgumentException- in case of missingDocumentannotation marking root entities.
-
createCompoundIndexDefinitions
protected List<MongoPersistentEntityIndexResolver.IndexDefinitionHolder> createCompoundIndexDefinitions(String dotPath, String fallbackCollection, MongoPersistentEntity<?> entity) CreateIndexDefinitionwrapped inMongoPersistentEntityIndexResolver.IndexDefinitionHolderforCompoundIndexesof a given type.- Parameters:
dotPath- The properties "dot" path representation from its document root.fallbackCollection-entity-- Returns:
-
createCompoundIndexDefinition
protected MongoPersistentEntityIndexResolver.IndexDefinitionHolder createCompoundIndexDefinition(String dotPath, String collection, CompoundIndex index, MongoPersistentEntity<?> entity) -
createWildcardIndexDefinition
protected MongoPersistentEntityIndexResolver.IndexDefinitionHolder createWildcardIndexDefinition(String dotPath, String collection, WildcardIndexed index, @Nullable MongoPersistentEntity<?> entity) -
createIndexDefinition
protected @Nullable MongoPersistentEntityIndexResolver.IndexDefinitionHolder createIndexDefinition(String dotPath, String collection, MongoPersistentProperty persistentProperty) CreatesIndexDefinitionwrapped inMongoPersistentEntityIndexResolver.IndexDefinitionHolderout ofIndexedfor a givenMongoPersistentProperty.- Parameters:
dotPath- The properties "dot" path representation from its document root.collection-persistentProperty-- Returns:
-
createHashedIndexDefinition
protected @Nullable MongoPersistentEntityIndexResolver.IndexDefinitionHolder createHashedIndexDefinition(String dotPath, String collection, MongoPersistentProperty persistentProperty) CreatesHashedIndexwrapped inMongoPersistentEntityIndexResolver.IndexDefinitionHolderout ofHashIndexedfor a givenMongoPersistentProperty.- Parameters:
dotPath- The properties "dot" path representation from its document root.collection-persistentProperty-- Returns:
- Since:
- 2.2
-
getEvaluationContext
Get the defaultEvaluationContext.- Returns:
- never null.
- Since:
- 2.2
-
setEvaluationContextProvider
Set theEvaluationContextProviderused for obtaining theEvaluationContextused to computeexpressions.- Parameters:
evaluationContextProvider- must not be null.- Since:
- 2.2
-
createGeoSpatialIndexDefinition
protected @Nullable MongoPersistentEntityIndexResolver.IndexDefinitionHolder createGeoSpatialIndexDefinition(String dotPath, String collection, MongoPersistentProperty persistentProperty) CreatesIndexDefinitionwrapped inMongoPersistentEntityIndexResolver.IndexDefinitionHolderout ofGeoSpatialIndexedforMongoPersistentProperty.- Parameters:
dotPath- The properties "dot" path representation from its document root.collection-persistentProperty-- Returns:
-