Package dev.morphia.converters
Class TypeConverter
- java.lang.Object
-
- dev.morphia.converters.TypeConverter
-
- Direct Known Subclasses:
BigDecimalConverter
,BooleanConverter
,ByteConverter
,CharacterConverter
,CharArrayConverter
,ClassConverter
,CurrencyConverter
,DateConverter
,DoubleConverter
,EnumConverter
,EnumSetConverter
,FloatConverter
,GeometryConverter
,GeometryQueryConverter
,GeometryShapeConverter
,IdentityConverter
,InstantConverter
,IntegerConverter
,IterableConverter
,KeyConverter
,LocalDateConverter
,LocalDateTimeConverter
,LocaleConverter
,LocalTimeConverter
,LongConverter
,MapOfValuesConverter
,NamedCoordinateReferenceSystemConverter
,ObjectIdConverter
,ReferenceConverter
,SerializedObjectConverter
,ShortConverter
,StringConverter
,URIConverter
,UUIDConverter
public abstract class TypeConverter extends java.lang.Object
- Author:
- Uwe Schaefer, (us@thomas-daily.de)
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TypeConverter()
protected
TypeConverter(java.lang.Class... types)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract java.lang.Object
decode(java.lang.Class<?> targetClass, java.lang.Object fromDBObject, MappedField optionalExtraInfo)
decode theDBObject
and provide the corresponding java (type-safe) object
NOTE: optionalExtraInfo might be nulljava.lang.Object
decode(java.lang.Class targetClass, java.lang.Object fromDBObject)
decode theDBObject
and provide the corresponding java (type-safe) objectjava.lang.Object
encode(java.lang.Object value)
encode the type safe java object into the correspondingDBObject
java.lang.Object
encode(java.lang.Object value, MappedField optionalExtraInfo)
encode the (type-safe) java object into the correspondingDBObject
boolean
equals(java.lang.Object obj)
Mapper
getMapper()
java.lang.Class[]
getSupportTypes()
Deprecated.use #getSupportedTypes()int
hashCode()
protected boolean
isSupported(java.lang.Class<?> c, MappedField optionalExtraInfo)
checks if the class is supported for this converter.protected boolean
oneOf(java.lang.Class f, java.lang.Class... classes)
checks if Class f is in classes *protected boolean
oneOfClasses(java.lang.Class f, java.lang.Class[] classes)
checks if Class f is in classes *void
setMapper(Mapper mapper)
Sets the Mapper to use.void
setSupportedTypes(java.lang.Class[] supportedTypes)
Sets the types supported by this converter.void
setSupportTypes(java.lang.Class[] supportTypes)
Deprecated.use #setSupportedTypes(Class[])
-
-
-
Method Detail
-
decode
public final java.lang.Object decode(java.lang.Class targetClass, java.lang.Object fromDBObject)
decode theDBObject
and provide the corresponding java (type-safe) object- Parameters:
targetClass
- the class to create and populatefromDBObject
- the DBObject to use when populating the new instance- Returns:
- the new instance
-
decode
public abstract java.lang.Object decode(java.lang.Class<?> targetClass, java.lang.Object fromDBObject, MappedField optionalExtraInfo)
decode theDBObject
and provide the corresponding java (type-safe) object
NOTE: optionalExtraInfo might be null- Parameters:
targetClass
- the class to create and populatefromDBObject
- the DBObject to use when populating the new instanceoptionalExtraInfo
- the MappedField that contains the metadata useful for decoding- Returns:
- the new instance
-
encode
public final java.lang.Object encode(java.lang.Object value)
encode the type safe java object into the correspondingDBObject
- Parameters:
value
- The object to encode- Returns:
- the encoded version of the object
-
encode
public java.lang.Object encode(java.lang.Object value, MappedField optionalExtraInfo)
encode the (type-safe) java object into the correspondingDBObject
- Parameters:
value
- The object to encodeoptionalExtraInfo
- the MappedField that contains the metadata useful for decoding- Returns:
- the encoded version of the object
-
getMapper
public Mapper getMapper()
- Returns:
- the mapper used by the converter
-
setMapper
public void setMapper(Mapper mapper)
Sets the Mapper to use.- Parameters:
mapper
- the Mapper to use
-
getSupportTypes
@Deprecated public java.lang.Class[] getSupportTypes()
Deprecated.use #getSupportedTypes()- Returns:
- an array of supported convertable types
-
setSupportTypes
@Deprecated public void setSupportTypes(java.lang.Class[] supportTypes)
Deprecated.use #setSupportedTypes(Class[])- Parameters:
supportTypes
- the types this converter supports
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
isSupported
protected boolean isSupported(java.lang.Class<?> c, MappedField optionalExtraInfo)
checks if the class is supported for this converter.
-
oneOf
protected boolean oneOf(java.lang.Class f, java.lang.Class... classes)
checks if Class f is in classes *
-
oneOfClasses
protected boolean oneOfClasses(java.lang.Class f, java.lang.Class[] classes)
checks if Class f is in classes *
-
setSupportedTypes
public void setSupportedTypes(java.lang.Class[] supportedTypes)
Sets the types supported by this converter.- Parameters:
supportedTypes
- the types this converter supports
-
-