Package dev.morphia
Interface ObjectFactory
-
public interface ObjectFactory
The ObjectFactory is used by morphia to create instances of classes which can be customized to fit a particular applications needs.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Object
createInstance(Mapper mapper, PropertyModel mf, org.bson.Document document)
Creates an instance of the class defined in the discriminator field in the document passed in.<T> T
createInstance(Class<T> clazz)
Creates an instance of the given class.<T> T
createInstance(Class<T> clazz, org.bson.Document document)
Creates an instance of the class defined in the discriminator field in the document passed in.List
createList(PropertyModel mf)
Defines how morphia creates a List object.Map
createMap(PropertyModel mf)
Defines how morphia creates a Map object.Set
createSet(PropertyModel mf)
Defines how morphia creates a Set object.
-
-
-
Method Detail
-
createInstance
<T> T createInstance(Class<T> clazz)
Creates an instance of the given class.- Type Parameters:
T
- the type of the entity- Parameters:
clazz
- type class to instantiate- Returns:
- the new instance
-
createInstance
<T> T createInstance(Class<T> clazz, org.bson.Document document)
Creates an instance of the class defined in the discriminator field in the document passed in. If that field is missing, the given Class is used instead.- Type Parameters:
T
- the type of the entity- Parameters:
clazz
- type class to instantiatedocument
- the state to populate the new instance with- Returns:
- the new instance
-
createInstance
Object createInstance(Mapper mapper, PropertyModel mf, org.bson.Document document)
Creates an instance of the class defined in the discriminator field in the document passed in. If that field is missing, morphia attempts to the MappedField to determine which concrete class to instantiate.- Parameters:
mapper
- the Mapper to usemf
- the MappedField to consult when creating the instancedocument
- the state to populate the new instance with- Returns:
- the new instance
-
createList
List createList(PropertyModel mf)
Defines how morphia creates a List object.- Parameters:
mf
- the MappedField containing any metadata that might define the type of the List to create- Returns:
- the List
-
createMap
Map createMap(PropertyModel mf)
Defines how morphia creates a Map object.- Parameters:
mf
- the MappedField containing any metadata that might define the type of the Map to create- Returns:
- the Map
-
createSet
Set createSet(PropertyModel mf)
Defines how morphia creates a Set object.- Parameters:
mf
- the MappedField containing any metadata that might define the type of the Set to create- Returns:
- the Set
-
-