Spring Data MongoDB - Core

org.springframework.data.mongodb.core.index
Class MongoPersistentEntityIndexResolver

java.lang.Object
  extended by org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver

public class MongoPersistentEntityIndexResolver
extends Object

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

Nested Class Summary
static class MongoPersistentEntityIndexResolver.CyclicPropertyReferenceException
           
static class MongoPersistentEntityIndexResolver.IndexDefinitionHolder
          Implementation of IndexDefinition holding additional (property)path information used for creating the index.
 
Constructor Summary
MongoPersistentEntityIndexResolver(MongoMappingContext mappingContext)
          Create new MongoPersistentEntityIndexResolver.
 
Method Summary
protected  MongoPersistentEntityIndexResolver.IndexDefinitionHolder createCompoundIndexDefinition(String dotPath, String fallbackCollection, CompoundIndex index)
           
protected  List<MongoPersistentEntityIndexResolver.IndexDefinitionHolder> createCompoundIndexDefinitions(String dotPath, String fallbackCollection, Class<?> type)
          Create IndexDefinition wrapped in MongoPersistentEntityIndexResolver.IndexDefinitionHolder for CompoundIndexes of given type.
protected  MongoPersistentEntityIndexResolver.IndexDefinitionHolder createGeoSpatialIndexDefinition(String dotPath, String fallbackCollection, MongoPersistentProperty persistentProperty)
          Creates IndexDefinition wrapped in MongoPersistentEntityIndexResolver.IndexDefinitionHolder out of GeoSpatialIndexed for MongoPersistentProperty.
protected  MongoPersistentEntityIndexResolver.IndexDefinitionHolder createIndexDefinition(String dotPath, String fallbackCollection, MongoPersistentProperty persitentProperty)
          Creates IndexDefinition wrapped in MongoPersistentEntityIndexResolver.IndexDefinitionHolder out of Indexed for given MongoPersistentProperty.
 List<MongoPersistentEntityIndexResolver.IndexDefinitionHolder> resolveIndexForClass(Class<?> type)
          Find and create IndexDefinitions for properties of given type.
 List<MongoPersistentEntityIndexResolver.IndexDefinitionHolder> resolveIndexForEntity(MongoPersistentEntity<?> root)
          Resolve the IndexDefinitions for given root entity by traversing MongoPersistentProperty scanning for index annotations Indexed, CompoundIndex and GeospatialIndex.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MongoPersistentEntityIndexResolver

public MongoPersistentEntityIndexResolver(MongoMappingContext mappingContext)
Create new MongoPersistentEntityIndexResolver.

Parameters:
mappingContext - must not be null.
Method Detail

resolveIndexForClass

public List<MongoPersistentEntityIndexResolver.IndexDefinitionHolder> resolveIndexForClass(Class<?> type)
Find and create IndexDefinitions for properties of given type. IndexDefinitions are created for properties and types with Indexed, CompoundIndexes or GeoSpatialIndexed.

Returns:
Empty Iterable in case no IndexDefinition could be resolved for type.

resolveIndexForEntity

public List<MongoPersistentEntityIndexResolver.IndexDefinitionHolder> resolveIndexForEntity(MongoPersistentEntity<?> root)
Resolve the IndexDefinitions for given root entity by traversing MongoPersistentProperty scanning for index annotations Indexed, CompoundIndex and GeospatialIndex. The given root has therefore to be annotated with Document.

Parameters:
root - must not be null.
Returns:
List of MongoPersistentEntityIndexResolver.IndexDefinitionHolder. Will never be null.
Throws:
IllegalArgumentException - in case of missing Document annotation marking root entities.

createCompoundIndexDefinitions

protected List<MongoPersistentEntityIndexResolver.IndexDefinitionHolder> createCompoundIndexDefinitions(String dotPath,
                                                                                                        String fallbackCollection,
                                                                                                        Class<?> type)
Create IndexDefinition wrapped in MongoPersistentEntityIndexResolver.IndexDefinitionHolder for CompoundIndexes of given type.

Parameters:
dotPath - The properties "dot" path representation from its document root.
fallbackCollection -
type -
Returns:

createCompoundIndexDefinition

protected MongoPersistentEntityIndexResolver.IndexDefinitionHolder createCompoundIndexDefinition(String dotPath,
                                                                                                 String fallbackCollection,
                                                                                                 CompoundIndex index)

createIndexDefinition

protected MongoPersistentEntityIndexResolver.IndexDefinitionHolder createIndexDefinition(String dotPath,
                                                                                         String fallbackCollection,
                                                                                         MongoPersistentProperty persitentProperty)
Creates IndexDefinition wrapped in MongoPersistentEntityIndexResolver.IndexDefinitionHolder out of Indexed for given MongoPersistentProperty.

Parameters:
dotPath - The properties "dot" path representation from its document root.
collection -
persitentProperty -
Returns:

createGeoSpatialIndexDefinition

protected MongoPersistentEntityIndexResolver.IndexDefinitionHolder createGeoSpatialIndexDefinition(String dotPath,
                                                                                                   String fallbackCollection,
                                                                                                   MongoPersistentProperty persistentProperty)
Creates IndexDefinition wrapped in MongoPersistentEntityIndexResolver.IndexDefinitionHolder out of GeoSpatialIndexed for MongoPersistentProperty.

Parameters:
dotPath - The properties "dot" path representation from its document root.
collection -
persistentProperty -
Returns:

Spring Data MongoDB - Core

Copyright © 2011-2014-2014 Pivotal Software, Inc.. All Rights Reserved.