public class DefaultPropertyTypeConverter extends Object implements PropertyTypeConverter
PropertyValueEntity.PersistedType
. Ultimately, data can be persisted as BLOB data, but must
be the last resort.Modifier and Type | Field and Description |
---|---|
protected static Map<Class<?>,PropertyValueEntity.PersistedType> |
defaultPersistedTypesByClass
An unmodifiable map of types and how they should be persisted
|
Constructor and Description |
---|
DefaultPropertyTypeConverter()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
protected void |
addTypeMapping(Class<?> clazz,
PropertyValueEntity.PersistedType targetType)
Allow subclasses to add further type mappings specific to the implementation
|
Serializable |
constructInstance(String clazzName)
Construct an instance of an object that was deemed to be
PropertyValueEntity.PersistedType.CONSTRUCTABLE . |
<T> T |
convert(Class<T> targetClass,
Serializable value)
Performs the conversion using
DefaultTypeConverter but also adds
special handling for enum types . |
PropertyValueEntity.PersistedType |
getPersistentType(Serializable value)
When external to persisted type mappings are not obvious, the persistence framework,
before persisting as
PropertyValueEntity.PersistedType.SERIALIZABLE , will give the converter
a chance to choose how the value must be persisted:
PropertyValueEntity.PersistedType.LONG
PropertyValueEntity.PersistedType.DOUBLE
PropertyValueEntity.PersistedType.STRING
PropertyValueEntity.PersistedType.SERIALIZABLE
PropertyValueEntity.PersistedType.CONSTRUCTABLE
The converter should return PropertyValueEntity.PersistedType.SERIALIZABLE if no further conversions
are possible. |
protected boolean |
isConstructable(Serializable value)
Determines if the value can be adequately recreated (to equality) by creating
a new instance.
|
protected static final Map<Class<?>,PropertyValueEntity.PersistedType> defaultPersistedTypesByClass
public DefaultPropertyTypeConverter()
protected void addTypeMapping(Class<?> clazz, PropertyValueEntity.PersistedType targetType)
clazz
- the class to be convertedtargetType
- the target persisted typeprotected boolean isConstructable(Serializable value)
Subclasses can override this to handle any well-known types, and in conjunction with
constructInstance(String)
, even choose to return true if it needs a
non-default constructor.
value
- the value to checkpublic Serializable constructInstance(String clazzName)
PropertyValueEntity.PersistedType.CONSTRUCTABLE
.constructInstance
in interface PropertyTypeConverter
clazzName
- the name of the classpublic PropertyValueEntity.PersistedType getPersistentType(Serializable value)
PropertyValueEntity.PersistedType.SERIALIZABLE
, will give the converter
a chance to choose how the value must be persisted:
PropertyValueEntity.PersistedType.LONG
PropertyValueEntity.PersistedType.DOUBLE
PropertyValueEntity.PersistedType.STRING
PropertyValueEntity.PersistedType.SERIALIZABLE
PropertyValueEntity.PersistedType.CONSTRUCTABLE
PropertyValueEntity.PersistedType.SERIALIZABLE
if no further conversions
are possible. Implicit in the return value is the converter's ability to do the
conversion when required.
If the converter can fully reconstruct an equal instance using just the name of the value's
class, then PropertyValueEntity.PersistedType.CONSTRUCTABLE
can be used.getPersistentType
in interface PropertyTypeConverter
value
- the value that does not have an obvious persistence slotpublic <T> T convert(Class<T> targetClass, Serializable value)
DefaultTypeConverter
but also adds
special handling for enum types
.convert
in interface PropertyTypeConverter
targetClass
- the desired type to convert tovalue
- the value to convertCopyright © 2005–2017 Alfresco Software. All rights reserved.