public abstract class Converters extends Object
| Constructor and Description |
|---|
Converters(Mapper mapper)
Creates a bundle with a particular Mapper.
|
| Modifier and Type | Method and Description |
|---|---|
TypeConverter |
addConverter(Class<? extends TypeConverter> clazz)
Adds a TypeConverter to this bundle.
|
TypeConverter |
addConverter(TypeConverter tc)
Add a type converter.
|
Object |
decode(Class c,
Object fromDBObject,
MappedField mf)
decode the
DBObject and provide the corresponding java (type-safe) object
NOTE: mf might be null |
Object |
encode(Class c,
Object o)
encode the type safe java object into the corresponding
DBObject |
Object |
encode(Object o)
encode the type safe java object into the corresponding
DBObject |
void |
fromDBObject(DBObject dbObj,
MappedField mf,
Object targetEntity)
Creates an entity and populates its state based on the dbObject given.
|
protected TypeConverter |
getEncoder(Class c) |
protected TypeConverter |
getEncoder(Object val,
MappedField mf) |
boolean |
hasDbObjectConverter(Class c) |
boolean |
hasDbObjectConverter(MappedField field) |
boolean |
hasSimpleValueConverter(Class c) |
boolean |
hasSimpleValueConverter(MappedField c) |
boolean |
hasSimpleValueConverter(Object o) |
boolean |
isRegistered(Class<? extends TypeConverter> tcClass) |
void |
removeConverter(TypeConverter tc)
Removes the type converter.
|
void |
toDBObject(Object containingObject,
MappedField mf,
DBObject dbObj,
MapperOptions opts)
Converts an entity to a DBObject
|
public Converters(Mapper mapper)
mapper - the Mapper to usepublic TypeConverter addConverter(Class<? extends TypeConverter> clazz)
clazz - the converter to addpublic TypeConverter addConverter(TypeConverter tc)
tc - the converter to addpublic Object decode(Class c, Object fromDBObject, MappedField mf)
DBObject and provide the corresponding java (type-safe) object
c - the class to create and populatefromDBObject - the DBObject to use when populating the new instancemf - the MappedField that contains the metadata useful for decodingpublic Object encode(Object o)
DBObjecto - The object to encodepublic Object encode(Class c, Object o)
DBObjectc - The type to use when encodingo - The object to encodepublic void fromDBObject(DBObject dbObj, MappedField mf, Object targetEntity)
dbObj - the object state to usemf - the MappedField containing the metadata to use when decoding in to a fieldtargetEntity - then entity to hold the state from the databasepublic boolean hasDbObjectConverter(MappedField field)
field - the field to check withpublic boolean hasDbObjectConverter(Class c)
c - the type to checkpublic boolean hasSimpleValueConverter(Object o)
o - the object/type to checkSimpleValueConverterpublic boolean hasSimpleValueConverter(Class c)
c - the type to checkSimpleValueConverterpublic boolean hasSimpleValueConverter(MappedField c)
c - the type to checkSimpleValueConverterpublic boolean isRegistered(Class<? extends TypeConverter> tcClass)
tcClass - the type to checkpublic void removeConverter(TypeConverter tc)
tc - the converter to removepublic void toDBObject(Object containingObject, MappedField mf, DBObject dbObj, MapperOptions opts)
containingObject - The object to convertmf - the MappedField to extractdbObj - the DBObject to populateopts - the options to applyprotected TypeConverter getEncoder(Class c)
protected TypeConverter getEncoder(Object val, MappedField mf)