public class TypeManagerImpl extends Object implements TypeManager, Serializable
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,TypeConverter> |
autoApplyConvertersByType
Map of TypeConverter keyed by type name that we should default to for this type (user-defined).
|
protected ClassLoaderResolver |
clr |
protected Map<Class,? super ContainerHandler> |
containerHandlersByClass
Map of ContainerHandlers, keyed by the container type class name.
|
protected Map<String,org.datanucleus.store.types.TypeManagerImpl.JavaType> |
javaTypes
Map of java types, keyed by the class name.
|
protected NucleusContext |
nucCtx |
protected Map<String,TypeConverter> |
typeConverterByName
Map of TypeConverter keyed by their symbolic name.
|
protected Map<TypeConverter,Class> |
typeConverterDatastoreTypeByConverter
Cache of TypeConverter datastore type, keyed by the converter.
|
protected Map<Class,Map<Class,TypeConverter>> |
typeConverterMap
Map of (Map of TypeConverter keyed by the datastore type), keyed by the member type.
|
protected Map<TypeConverter,Class> |
typeConverterMemberTypeByConverter
Cache of TypeConverter member type, keyed by the converter.
|
| Constructor and Description |
|---|
TypeManagerImpl(NucleusContext nucCtx)
Constructor, loading support for type mappings using the plugin mechanism.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
SCO |
createSCOInstance(ObjectProvider ownerOP,
AbstractMemberMetaData mmd,
Class instantiatedType,
Object value,
boolean replaceField)
Method to create a new SCO wrapper for the specified member.
|
String[] |
filterOutSupportedSecondClassNames(String[] inputClassNames)
Convenience method to filter out any supported classes from a list.
|
protected org.datanucleus.store.types.TypeManagerImpl.JavaType |
findJavaTypeForClass(Class cls)
Convenience method to return the JavaType for the specified class.
|
protected org.datanucleus.store.types.TypeManagerImpl.JavaType |
findJavaTypeForCollectionClass(Class cls,
Class genericType)
Convenience method to return the JavaType for the specified class.
|
TypeConverter |
getAutoApplyTypeConverterForType(Class memberType)
Method to return a TypeConverter that should be applied by default for the specified java (member) type.
|
ContainerAdapter |
getContainerAdapter(Object container)
Convenience method to obtain the ContainerAdapter using the container object instance
|
<H extends ContainerHandler> |
getContainerHandler(Class containerClass)
Obtains the registered ContainerHandler for the given containerClass.
|
Class |
getDatastoreTypeForTypeConverter(TypeConverter conv,
Class memberType)
Method to return the datastore type for the specified TypeConverter.
|
TypeConverter |
getDefaultTypeConverterForType(Class memberType)
Accessor for the default type converter for the provided Java type.
|
Class |
getMemberTypeForTypeConverter(TypeConverter conv,
Class datastoreType)
Method to return the member type for the specified TypeConverter.
|
Set<String> |
getSupportedSecondClassTypes()
Accessor for the supported second-class Types.
|
TypeConverter |
getTypeConverterForName(String converterName)
Accessor for the type converter with the provided name.
|
TypeConverter |
getTypeConverterForType(Class memberType,
Class datastoreType)
Accessor for the type converter for the provided Java type and its datastore type.
|
Collection<TypeConverter> |
getTypeConvertersForType(Class memberType)
Accessor for the available type converters for the provided Java type.
|
Class |
getTypeForSecondClassWrapper(String className)
Accessor for a java type that the supplied class is a SCO wrapper for.
|
Class |
getWrappedTypeBackedForType(String className)
Accessor for the backing-store Second Class Wrapper class for the supplied class.
|
Class |
getWrapperTypeForType(String className)
Accessor for the SCO wrapper for the type
|
boolean |
isDefaultEmbeddedType(Class c)
Accessor for whether the type is by default embedded.
|
boolean |
isDefaultFetchGroup(Class c)
Accessor for whether the type is by default in the DFG.
|
boolean |
isDefaultFetchGroupForCollection(Class c,
Class genericType)
Accessor for whether the generic collection type is by default in the DFG.
|
boolean |
isDefaultPersistent(Class c)
Accessor for whether the type is by default persistent.
|
boolean |
isSecondClassMutableType(String className)
Accessor for whether the type is SCO mutable.
|
boolean |
isSecondClassWrapper(String className)
Accessor for whether the type is a SCO wrapper itself.
|
boolean |
isSupportedSecondClassType(String className)
Accessor for whether a class is supported as being second class.
|
void |
registerConverter(String name,
TypeConverter converter,
Class memberType,
Class dbType,
boolean autoApply,
String autoApplyType)
Register a TypeConverter with the TypeManager process for specific attribute/db types.
|
void |
setDefaultTypeConverterForType(Class memberType,
String converterName)
Method providing the ability for a datastore plugin to override the default converter type for the specified java type.
|
Object |
wrapAndReplaceSCOField(ObjectProvider ownerOP,
int memberNumber,
Object newValue,
Object oldValue,
boolean replaceFieldIfChanged)
Method to create a new SCO wrapper for the specified field replacing the old value with the new value.
|
protected NucleusContext nucCtx
protected transient ClassLoaderResolver clr
protected Map<String,org.datanucleus.store.types.TypeManagerImpl.JavaType> javaTypes
protected Map<Class,? super ContainerHandler> containerHandlersByClass
protected Map<String,TypeConverter> typeConverterByName
protected Map<String,TypeConverter> autoApplyConvertersByType
protected Map<Class,Map<Class,TypeConverter>> typeConverterMap
protected Map<TypeConverter,Class> typeConverterDatastoreTypeByConverter
protected Map<TypeConverter,Class> typeConverterMemberTypeByConverter
public TypeManagerImpl(NucleusContext nucCtx)
nucCtx - NucleusContextpublic void close()
close in interface TypeManagerpublic Set<String> getSupportedSecondClassTypes()
TypeManagergetSupportedSecondClassTypes in interface TypeManagerpublic boolean isSupportedSecondClassType(String className)
TypeManagerisSupportedSecondClassType in interface TypeManagerclassName - The class namepublic String[] filterOutSupportedSecondClassNames(String[] inputClassNames)
TypeManagerfilterOutSupportedSecondClassNames in interface TypeManagerinputClassNames - Names of the classespublic boolean isDefaultPersistent(Class c)
TypeManagerisDefaultPersistent in interface TypeManagerc - The typepublic boolean isDefaultFetchGroup(Class c)
TypeManagerisDefaultFetchGroup in interface TypeManagerc - The typepublic boolean isDefaultFetchGroupForCollection(Class c, Class genericType)
TypeManagerisDefaultFetchGroupForCollection in interface TypeManagerc - The typegenericType - The element generic typepublic boolean isDefaultEmbeddedType(Class c)
TypeManagerisDefaultEmbeddedType in interface TypeManagerc - The typepublic boolean isSecondClassMutableType(String className)
TypeManagerisSecondClassMutableType in interface TypeManagerclassName - The typepublic Class getWrapperTypeForType(String className)
TypeManagergetWrapperTypeForType in interface TypeManagerclassName - The typepublic Class getWrappedTypeBackedForType(String className)
TypeManagergetWrappedTypeBackedForType in interface TypeManagerclassName - The class namepublic boolean isSecondClassWrapper(String className)
TypeManagerisSecondClassWrapper in interface TypeManagerclassName - The typepublic SCO createSCOInstance(ObjectProvider ownerOP, AbstractMemberMetaData mmd, Class instantiatedType, Object value, boolean replaceField)
TypeManagercreateSCOInstance in interface TypeManagerownerOP - ObjectProvider managing the instancemmd - Metadata for the member in questioninstantiatedType - The instantiated typevalue - The value to wrapreplaceField - Whether to replace the field in the owner objectpublic Object wrapAndReplaceSCOField(ObjectProvider ownerOP, int memberNumber, Object newValue, Object oldValue, boolean replaceFieldIfChanged)
wrapAndReplaceSCOField in interface TypeManagerownerOP - The ObjectProvider of the owner objectmemberNumber - The member number in the ownernewValue - The value to initialise the wrapper with (if any) for this memberoldValue - The previous value that we are replacing with this valuereplaceFieldIfChanged - Whether to replace the member in the object if wrapping the valuepublic Class getTypeForSecondClassWrapper(String className)
TypeManagergetTypeForSecondClassWrapper in interface TypeManagerclassName - Name of the classpublic ContainerAdapter getContainerAdapter(Object container)
TypeManagergetContainerAdapter in interface TypeManagercontainer - The container instancepublic <H extends ContainerHandler> H getContainerHandler(Class containerClass)
TypeManagergetContainerHandler in interface TypeManagerH - Handler typecontainerClass - The class of the container.public TypeConverter getTypeConverterForName(String converterName)
TypeManagergetTypeConverterForName in interface TypeManagerconverterName - Name of the converterpublic void registerConverter(String name, TypeConverter converter, Class memberType, Class dbType, boolean autoApply, String autoApplyType)
TypeManagerregisterConverter in interface TypeManagername - The name to register the converter underconverter - The convertermemberType - Type of the java memberdbType - Type of the database columnautoApply - Whether this should be used as an auto-apply converterautoApplyType - Java type to auto apply this forpublic TypeConverter getAutoApplyTypeConverterForType(Class memberType)
TypeManagergetAutoApplyTypeConverterForType in interface TypeManagermemberType - The java (member) typepublic void setDefaultTypeConverterForType(Class memberType, String converterName)
TypeManagersetDefaultTypeConverterForType in interface TypeManagermemberType - Member typeconverterName - The converter to use by default. This is assumed to exist.public TypeConverter getDefaultTypeConverterForType(Class memberType)
TypeManagergetDefaultTypeConverterForType in interface TypeManagermemberType - Java type for the memberpublic TypeConverter getTypeConverterForType(Class memberType, Class datastoreType)
TypeManagergetTypeConverterForType in interface TypeManagermemberType - Java type for the memberdatastoreType - Java type for the datastorepublic Collection<TypeConverter> getTypeConvertersForType(Class memberType)
TypeManagergetTypeConvertersForType in interface TypeManagermemberType - The java typepublic Class getDatastoreTypeForTypeConverter(TypeConverter conv, Class memberType)
getDatastoreTypeForTypeConverter in interface TypeManagerconv - The convertermemberType - The member typepublic Class getMemberTypeForTypeConverter(TypeConverter conv, Class datastoreType)
getMemberTypeForTypeConverter in interface TypeManagerconv - The converterdatastoreType - The datastore type for this converterprotected org.datanucleus.store.types.TypeManagerImpl.JavaType findJavaTypeForClass(Class cls)
cls - The class requiredprotected org.datanucleus.store.types.TypeManagerImpl.JavaType findJavaTypeForCollectionClass(Class cls, Class genericType)
cls - The class requiredgenericType - Any generic type specified for the elementCopyright © 2020. All rights reserved.