Class MongoIndexable<SpecT,IndexedT>
java.lang.Object
dev.getelements.elements.dao.mongo.MongoIndexable<SpecT,IndexedT>
- All Implemented Interfaces:
Indexable
- Direct Known Subclasses:
MongoIndexable.DistinctInventoryItem,MongoIndexable.Item,MongoIndexable.Metadata
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic class -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMongoIndexable(Class<SpecT> spec, Class<IndexedT> indexed) Creates a new MongoIndexable instance with the default name and metadata spec extractors.MongoIndexable(Class<SpecT> spec, Class<IndexedT> indexed, Function<SpecT, String> nameExtractor, Function<SpecT, MongoMetadataSpec> metadataSpecExtractor) Creates a new MongoIndexable instance with the default name and metadata spec extractors. -
Method Summary
Modifier and TypeMethodDescriptionvoidBuilds the indexes based on the last plan operation.protected IndexMetadata<org.bson.Document> generate(Path path, MetadataSpecProperty metadataSpecProperty) Generates the index metadata for the given path and metadata spec property.protected com.mongodb.client.MongoCollection<IndexedT> Returns the collection which will be indexed.protected StringReturns the name of the collection which will be indexed.dev.morphia.Datastorevoidplan()Plans the indexes.voidsetDatastore(dev.morphia.Datastore datastore) voidsetMapper(MapperRegistry mapperRegistry) protected voidupdatePlanWithMetadataSpecs(IndexPlanner<org.bson.Document> planner) Updates the index plan with metadata specifications.
-
Field Details
-
spec
-
indexed
-
nameExtractor
-
metadataSpecExtractor
-
-
Constructor Details
-
MongoIndexable
Creates a new MongoIndexable instance with the default name and metadata spec extractors.- Parameters:
spec- the type that contains the specification and unique nameindexed- the type that will be indexed based on the spec provided
-
MongoIndexable
public MongoIndexable(Class<SpecT> spec, Class<IndexedT> indexed, Function<SpecT, String> nameExtractor, Function<SpecT, MongoMetadataSpec> metadataSpecExtractor) Creates a new MongoIndexable instance with the default name and metadata spec extractors. This allows for specification of custom name and metadata spec extractors in case the default bean properties ones are not sufficient.- Parameters:
spec- the type that contains the specification and unique nameindexed- the type that will be indexed based on the spec provided
-
-
Method Details
-
plan
public void plan()Description copied from interface:IndexablePlans the indexes. Writing the contents of the to-be indexed content to the database. -
getCollection
Returns the collection which will be indexed.- Returns:
- the collection
-
getCollectionName
Returns the name of the collection which will be indexed.- Returns:
- the collection name
-
generate
protected IndexMetadata<org.bson.Document> generate(Path path, MetadataSpecProperty metadataSpecProperty) Generates the index metadata for the given path and metadata spec property.- Parameters:
path- the path to generate the index formetadataSpecProperty- the metadata spec property to use- Returns:
- the generated index metadata
-
updatePlanWithMetadataSpecs
Updates the index plan with metadata specifications.- Parameters:
planner- the index planner to update
-
buildIndexes
public void buildIndexes()Description copied from interface:IndexableBuilds the indexes based on the last plan operation.- Specified by:
buildIndexesin interfaceIndexable
-
getMapper
-
setMapper
-
getDatastore
public dev.morphia.Datastore getDatastore() -
setDatastore
@Inject public void setDatastore(dev.morphia.Datastore datastore)
-