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
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
Implementation ofIndexDefinition
holding additional (property)path information used for creating the index. -
Constructor Summary
ConstructorDescriptionMongoPersistentEntityIndexResolver
(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) CreateIndexDefinition
wrapped inMongoPersistentEntityIndexResolver.IndexDefinitionHolder
forCompoundIndexes
of a given type.createGeoSpatialIndexDefinition
(String dotPath, String collection, MongoPersistentProperty persistentProperty) CreatesIndexDefinition
wrapped inMongoPersistentEntityIndexResolver.IndexDefinitionHolder
out ofGeoSpatialIndexed
forMongoPersistentProperty
.createHashedIndexDefinition
(String dotPath, String collection, MongoPersistentProperty persistentProperty) CreatesHashedIndex
wrapped inMongoPersistentEntityIndexResolver.IndexDefinitionHolder
out ofHashIndexed
for a givenMongoPersistentProperty
.createIndexDefinition
(String dotPath, String collection, MongoPersistentProperty persistentProperty) CreatesIndexDefinition
wrapped inMongoPersistentEntityIndexResolver.IndexDefinitionHolder
out ofIndexed
for a givenMongoPersistentProperty
.createWildcardIndexDefinition
(String dotPath, String collection, WildcardIndexed index, MongoPersistentEntity<?> entity) protected EvaluationContext
Get the defaultEvaluationContext
.resolveIndexFor
(TypeInformation<?> typeInformation) Find and createIndexDefinition
s for properties of givenTypeInformation
.Resolve theIndexDefinition
s for a given root entity by traversingMongoPersistentProperty
scanning for index annotationsIndexed
,CompoundIndex
andGeospatialIndex
.void
setEvaluationContextProvider
(EvaluationContextProvider evaluationContextProvider) Set theEvaluationContextProvider
used for obtaining theEvaluationContext
used to computeexpressions
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.data.mongodb.core.index.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:IndexResolver
Find and createIndexDefinition
s for properties of givenTypeInformation
.IndexDefinition
s are created for properties and types withIndexed
,CompoundIndexes
orGeoSpatialIndexed
.- Specified by:
resolveIndexFor
in interfaceIndexResolver
- Parameters:
typeInformation
- must not be null.- Returns:
- Empty
Iterable
in case noIndexDefinition
could be resolved for type.
-
resolveIndexForEntity
public List<MongoPersistentEntityIndexResolver.IndexDefinitionHolder> resolveIndexForEntity(MongoPersistentEntity<?> root) Resolve theIndexDefinition
s for a given root entity by traversingMongoPersistentProperty
scanning for index annotationsIndexed
,CompoundIndex
andGeospatialIndex
. The given root has therefore to be annotated withDocument
.- Parameters:
root
- must not be null.- Returns:
- List of
MongoPersistentEntityIndexResolver.IndexDefinitionHolder
. Will never benull
. - Throws:
IllegalArgumentException
- in case of missingDocument
annotation marking root entities.
-
createCompoundIndexDefinitions
protected List<MongoPersistentEntityIndexResolver.IndexDefinitionHolder> createCompoundIndexDefinitions(String dotPath, String fallbackCollection, MongoPersistentEntity<?> entity) CreateIndexDefinition
wrapped inMongoPersistentEntityIndexResolver.IndexDefinitionHolder
forCompoundIndexes
of 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
@Nullable protected MongoPersistentEntityIndexResolver.IndexDefinitionHolder createIndexDefinition(String dotPath, String collection, MongoPersistentProperty persistentProperty) CreatesIndexDefinition
wrapped inMongoPersistentEntityIndexResolver.IndexDefinitionHolder
out ofIndexed
for a givenMongoPersistentProperty
.- Parameters:
dotPath
- The properties "dot" path representation from its document root.collection
-persistentProperty
-- Returns:
-
createHashedIndexDefinition
@Nullable protected MongoPersistentEntityIndexResolver.IndexDefinitionHolder createHashedIndexDefinition(String dotPath, String collection, MongoPersistentProperty persistentProperty) CreatesHashedIndex
wrapped inMongoPersistentEntityIndexResolver.IndexDefinitionHolder
out ofHashIndexed
for 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 theEvaluationContextProvider
used for obtaining theEvaluationContext
used to computeexpressions
.- Parameters:
evaluationContextProvider
- must not be null.- Since:
- 2.2
-
createGeoSpatialIndexDefinition
@Nullable protected MongoPersistentEntityIndexResolver.IndexDefinitionHolder createGeoSpatialIndexDefinition(String dotPath, String collection, MongoPersistentProperty persistentProperty) CreatesIndexDefinition
wrapped inMongoPersistentEntityIndexResolver.IndexDefinitionHolder
out ofGeoSpatialIndexed
forMongoPersistentProperty
.- Parameters:
dotPath
- The properties "dot" path representation from its document root.collection
-persistentProperty
-- Returns:
-