public abstract class TypeConverter extends Object
| Modifier | Constructor and Description |
|---|---|
protected |
TypeConverter() |
protected |
TypeConverter(Class... types) |
| Modifier and Type | Method and Description |
|---|---|
abstract Object |
decode(Class<?> targetClass,
Object fromDBObject,
MappedField optionalExtraInfo)
decode the
DBObject and provide the corresponding java (type-safe) object NOTE: optionalExtraInfo might be null |
Object |
decode(Class targetClass,
Object fromDBObject)
decode the
DBObject and provide the corresponding java (type-safe) object |
Object |
encode(Object value)
encode the type safe java object into the corresponding
DBObject |
Object |
encode(Object value,
MappedField optionalExtraInfo)
encode the (type-safe) java object into the corresponding
DBObject |
boolean |
equals(Object obj) |
Mapper |
getMapper() |
Class[] |
getSupportTypes()
Deprecated.
use #getSupportedTypes()
|
int |
hashCode() |
protected boolean |
isSupported(Class<?> c,
MappedField optionalExtraInfo)
checks if the class is supported for this converter.
|
protected boolean |
oneOf(Class f,
Class... classes)
checks if Class f is in classes *
|
protected boolean |
oneOfClasses(Class f,
Class[] classes)
checks if Class f is in classes *
|
void |
setMapper(Mapper mapper)
Sets the Mapper to use.
|
void |
setSupportedTypes(Class[] supportedTypes)
Sets the types supported by this converter.
|
void |
setSupportTypes(Class[] supportTypes)
Deprecated.
use #setSupportedTypes(Class[])
|
protected TypeConverter()
protected TypeConverter(Class... types)
public final Object decode(Class targetClass, Object fromDBObject)
DBObject and provide the corresponding java (type-safe) objecttargetClass - the class to create and populatefromDBObject - the DBObject to use when populating the new instancepublic abstract Object decode(Class<?> targetClass, Object fromDBObject, MappedField optionalExtraInfo)
DBObject and provide the corresponding java (type-safe) object targetClass - the class to create and populatefromDBObject - the DBObject to use when populating the new instanceoptionalExtraInfo - the MappedField that contains the metadata useful for decodingpublic final Object encode(Object value)
DBObjectvalue - The object to encodepublic Object encode(Object value, MappedField optionalExtraInfo)
DBObjectvalue - The object to encodeoptionalExtraInfo - the MappedField that contains the metadata useful for decodingpublic Mapper getMapper()
public void setMapper(Mapper mapper)
mapper - the Mapper to use@Deprecated public Class[] getSupportTypes()
@Deprecated public void setSupportTypes(Class[] supportTypes)
supportTypes - the types this converter supportsprotected boolean isSupported(Class<?> c, MappedField optionalExtraInfo)
protected boolean oneOfClasses(Class f, Class[] classes)
public void setSupportedTypes(Class[] supportedTypes)
supportedTypes - the types this converter supports