Package de.caluga.morphium.objectmapping
Class ObjectMapperImpl
- java.lang.Object
-
- de.caluga.morphium.objectmapping.ObjectMapperImpl
-
- All Implemented Interfaces:
MorphiumObjectMapper
public class ObjectMapperImpl extends Object implements MorphiumObjectMapper
User: Stpehan Bösebeck Date: 26.03.12 Time: 19:36
-
-
Constructor Summary
Constructors Constructor Description ObjectMapperImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidderegisterCustomMapperFor(Class cls)<T> Tdeserialize(Class<? extends T> cls, String jsonString)<T> Tdeserialize(Class<? extends T> theClass, Map<String,Object> objectMap)ListdeserializeList(List<Object> lst)Map<String,Object>deserializeMap(Map<String,Object> dbObject)ObjectfillArray(Class<?> componentType, Collection<?> c)ObjectfillCollection(Reference ref, Class<?> collectionClass, Type collectionType, List<?> fromDb)protected MapfillMap(Type mapType, Map<String,Object> fromDB)protected voidfillMap(Type mapType, Map<String,Object> fromDB, Map toFillIn)Class<?>getClassForCollectionName(String collectionName)StringgetCollectionName(Class cls)static TypegetElementType(ParameterizedType parameterizedType)MorphiumgetMorphium()NameProvidergetNameProviderForClass(Class<?> cls)get current name provider for classObjectmarshallIfNecessary(Object o)<T> voidregisterCustomMapperFor(Class<T> cls, MorphiumTypeMapper<T> map)Map<String,Object>serialize(Object o)ObjectserializeEnum(Class<?> declaredClass, Enum val)List<Object>serializeIterable(Iterable v, Class<?> collectionClass, Type collectionType)Map<String,Object>serializeMap(Map v, Type mapType)voidsetAnnotationHelper(AnnotationAndReflectionHelper an)voidsetMorphium(Morphium m)will automatically be called after instanciation by Morphium also gets the AnnotationAndReflectionHelper from this object (to make use of the caches)voidsetNameProviderForClass(Class<?> cls, NameProvider np)override nameprovider in runtime!
-
-
-
Method Detail
-
setAnnotationHelper
public void setAnnotationHelper(AnnotationAndReflectionHelper an)
- Specified by:
setAnnotationHelperin interfaceMorphiumObjectMapper
-
getMorphium
public Morphium getMorphium()
- Specified by:
getMorphiumin interfaceMorphiumObjectMapper
-
setMorphium
public void setMorphium(Morphium m)
will automatically be called after instanciation by Morphium also gets the AnnotationAndReflectionHelper from this object (to make use of the caches)- Specified by:
setMorphiumin interfaceMorphiumObjectMapper- Parameters:
m- - the Morphium instance
-
setNameProviderForClass
public void setNameProviderForClass(Class<?> cls, NameProvider np)
override nameprovider in runtime!- Specified by:
setNameProviderForClassin interfaceMorphiumObjectMapper- Parameters:
cls- - class to usenp- - the NameProvider for that class
-
registerCustomMapperFor
public <T> void registerCustomMapperFor(Class<T> cls, MorphiumTypeMapper<T> map)
- Specified by:
registerCustomMapperForin interfaceMorphiumObjectMapper
-
deregisterCustomMapperFor
public void deregisterCustomMapperFor(Class cls)
- Specified by:
deregisterCustomMapperForin interfaceMorphiumObjectMapper
-
getNameProviderForClass
public NameProvider getNameProviderForClass(Class<?> cls)
Description copied from interface:MorphiumObjectMapperget current name provider for class- Specified by:
getNameProviderForClassin interfaceMorphiumObjectMapper- Parameters:
cls- - class- Returns:
- configured name provider in @Entity or currently set one
-
getCollectionName
public String getCollectionName(Class cls)
- Specified by:
getCollectionNamein interfaceMorphiumObjectMapper
-
serialize
public Map<String,Object> serialize(Object o)
- Specified by:
serializein interfaceMorphiumObjectMapper
-
serializeIterable
public List<Object> serializeIterable(Iterable v, Class<?> collectionClass, Type collectionType)
-
deserialize
public <T> T deserialize(Class<? extends T> cls, String jsonString) throws org.json.simple.parser.ParseException
- Specified by:
deserializein interfaceMorphiumObjectMapper- Throws:
org.json.simple.parser.ParseException
-
deserialize
public <T> T deserialize(Class<? extends T> theClass, Map<String,Object> objectMap)
- Specified by:
deserializein interfaceMorphiumObjectMapper
-
fillArray
public Object fillArray(Class<?> componentType, Collection<?> c)
-
fillCollection
public Object fillCollection(Reference ref, Class<?> collectionClass, Type collectionType, List<?> fromDb)
-
getElementType
public static Type getElementType(ParameterizedType parameterizedType)
-
getClassForCollectionName
public Class<?> getClassForCollectionName(String collectionName)
- Specified by:
getClassForCollectionNamein interfaceMorphiumObjectMapper
-
-