Package dev.morphia.mapping
Class DefaultCreator
- java.lang.Object
-
- dev.morphia.mapping.DefaultCreator
-
- All Implemented Interfaces:
ObjectFactory
public class DefaultCreator extends java.lang.Object implements ObjectFactory
- Author:
- ScottHernandez
-
-
Constructor Summary
Constructors Constructor Description DefaultCreator()
Creates a new DefaultCreator with no optionsDefaultCreator(MapperOptions options)
Creates a new DefaultCreator with options
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <T> T
createInst(java.lang.Class<T> clazz)
Deprecated.usecreateInstance(Class)
insteadjava.lang.Object
createInstance(Mapper mapper, MappedField mf, com.mongodb.DBObject dbObj)
Creates an instance of the class defined in the discriminator field in the dbObject passed in.<T> T
createInstance(java.lang.Class<T> clazz)
Creates an instance of the given class.<T> T
createInstance(java.lang.Class<T> clazz, com.mongodb.DBObject dbObj)
Creates an instance of the class defined in the discriminator field in the dbObject passed in.java.util.List
createList(MappedField mf)
Defines how morphia creates a List object.java.util.Map
createMap(MappedField mf)
Defines how morphia creates a Map object.java.util.Set
createSet(MappedField mf)
Defines how morphia creates a Set object.java.util.Map<java.lang.String,java.lang.Class>
getClassNameCache()
-
-
-
Constructor Detail
-
DefaultCreator
public DefaultCreator()
Creates a new DefaultCreator with no options
-
DefaultCreator
public DefaultCreator(MapperOptions options)
Creates a new DefaultCreator with options- Parameters:
options
- the options to apply
-
-
Method Detail
-
createInst
@Deprecated public <T> T createInst(java.lang.Class<T> clazz)
Deprecated.usecreateInstance(Class)
instead- Type Parameters:
T
- the type of the class- Parameters:
clazz
- the Class of the type to create- Returns:
- the new instance
-
createInstance
public <T> T createInstance(java.lang.Class<T> clazz)
Description copied from interface:ObjectFactory
Creates an instance of the given class.- Specified by:
createInstance
in interfaceObjectFactory
- Type Parameters:
T
- the type of the entity- Parameters:
clazz
- type class to instantiate- Returns:
- the new instance
-
createInstance
public <T> T createInstance(java.lang.Class<T> clazz, com.mongodb.DBObject dbObj)
Description copied from interface:ObjectFactory
Creates an instance of the class defined in the discriminator field in the dbObject passed in. If that field is missing, the given Class is used instead.- Specified by:
createInstance
in interfaceObjectFactory
- Type Parameters:
T
- the type of the entity- Parameters:
clazz
- type class to instantiatedbObj
- the state to populate the new instance with- Returns:
- the new instance
-
createInstance
public java.lang.Object createInstance(Mapper mapper, MappedField mf, com.mongodb.DBObject dbObj)
Description copied from interface:ObjectFactory
Creates an instance of the class defined in the discriminator field in the dbObject passed in. If that field is missing, morphia attempts to the MappedField to determine which concrete class to instantiate.- Specified by:
createInstance
in interfaceObjectFactory
- Parameters:
mapper
- the Mapper to usemf
- the MappedField to consult when creating the instancedbObj
- the state to populate the new instance with- Returns:
- the new instance
-
createList
public java.util.List createList(MappedField mf)
Description copied from interface:ObjectFactory
Defines how morphia creates a List object.- Specified by:
createList
in interfaceObjectFactory
- Parameters:
mf
- the MappedField containing any metadata that might define the type of the List to create- Returns:
- the List
-
createMap
public java.util.Map createMap(MappedField mf)
Description copied from interface:ObjectFactory
Defines how morphia creates a Map object.- Specified by:
createMap
in interfaceObjectFactory
- Parameters:
mf
- the MappedField containing any metadata that might define the type of the Map to create- Returns:
- the Map
-
createSet
public java.util.Set createSet(MappedField mf)
Description copied from interface:ObjectFactory
Defines how morphia creates a Set object.- Specified by:
createSet
in interfaceObjectFactory
- Parameters:
mf
- the MappedField containing any metadata that might define the type of the Set to create- Returns:
- the Set
-
getClassNameCache
public java.util.Map<java.lang.String,java.lang.Class> getClassNameCache()
- Returns:
- the cache of classnames
-
-