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> TcreateInst(java.lang.Class<T> clazz)Deprecated.usecreateInstance(Class)insteadjava.lang.ObjectcreateInstance(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> TcreateInstance(java.lang.Class<T> clazz)Creates an instance of the given class.<T> TcreateInstance(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.ListcreateList(MappedField mf)Defines how morphia creates a List object.java.util.MapcreateMap(MappedField mf)Defines how morphia creates a Map object.java.util.SetcreateSet(MappedField mf)Defines how morphia creates a Set object.protected java.lang.ClassLoadergetClassLoaderForClass()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:ObjectFactoryCreates an instance of the given class.- Specified by:
createInstancein 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:ObjectFactoryCreates 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:
createInstancein 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:ObjectFactoryCreates 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:
createInstancein 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:ObjectFactoryDefines how morphia creates a List object.- Specified by:
createListin 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:ObjectFactoryDefines how morphia creates a Map object.- Specified by:
createMapin 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:ObjectFactoryDefines how morphia creates a Set object.- Specified by:
createSetin 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
-
getClassLoaderForClass
protected java.lang.ClassLoader getClassLoaderForClass()
-
-