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 protectedTypeConverter()protectedTypeConverter(java.lang.Class... types)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract java.lang.Objectdecode(java.lang.Class<?> targetClass, java.lang.Object fromDBObject, MappedField optionalExtraInfo)decode theDBObjectand provide the corresponding java (type-safe) object
NOTE: optionalExtraInfo might be nulljava.lang.Objectdecode(java.lang.Class targetClass, java.lang.Object fromDBObject)decode theDBObjectand provide the corresponding java (type-safe) objectjava.lang.Objectencode(java.lang.Object value)encode the type safe java object into the correspondingDBObjectjava.lang.Objectencode(java.lang.Object value, MappedField optionalExtraInfo)encode the (type-safe) java object into the correspondingDBObjectbooleanequals(java.lang.Object obj)MappergetMapper()java.lang.Class[]getSupportTypes()Deprecated.use #getSupportedTypes()inthashCode()protected booleanisSupported(java.lang.Class<?> c, MappedField optionalExtraInfo)checks if the class is supported for this converter.protected booleanoneOf(java.lang.Class f, java.lang.Class... classes)checks if Class f is in classes *protected booleanoneOfClasses(java.lang.Class f, java.lang.Class[] classes)checks if Class f is in classes *voidsetMapper(Mapper mapper)Sets the Mapper to use.voidsetSupportedTypes(java.lang.Class[] supportedTypes)Sets the types supported by this converter.voidsetSupportTypes(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 theDBObjectand 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 theDBObjectand 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:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin 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
-
-