Class GenericJsonSerializer<T>
java.lang.Object
de.iip_ecosphere.platform.transport.serialization.GenericJsonSerializer<T>
- Type Parameters:
T- the class to be serialized
- All Implemented Interfaces:
InputTypeTranslator<byte[],,T> OutputTypeTranslator<T,,byte[]> Serializer<T>,TypeTranslator<T,byte[]>
A simple, generic, reusable JSON serializer.
- Author:
- Holger Eichelberger, SSE
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGenericJsonSerializer(Class<T> cls) Implements a simple generic JSON serializer. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new value instance and copies the values fromoriginto the new instance.from(byte[] data) Deserializes a target value into a source value ("input from external").de.iip_ecosphere.platform.support.json.JsonReturns the object mapper.getType()The type to be handled by this serializer.byte[]Translates a source value into a target value ("output to external").
-
Field Details
-
mapper
private de.iip_ecosphere.platform.support.json.Json mapper -
cls
-
-
Constructor Details
-
GenericJsonSerializer
Implements a simple generic JSON serializer.- Parameters:
cls- the class to be serialized
-
-
Method Details
-
getMapper
public de.iip_ecosphere.platform.support.json.Json getMapper()Returns the object mapper.- Returns:
- the mapper
-
from
Description copied from interface:InputTypeTranslatorDeserializes a target value into a source value ("input from external").- Specified by:
fromin interfaceInputTypeTranslator<byte[],T> - Parameters:
data- the data to be translated back- Returns:
- the serialized object
- Throws:
IOException- in case that serialization fails
-
to
Description copied from interface:OutputTypeTranslatorTranslates a source value into a target value ("output to external").- Specified by:
toin interfaceOutputTypeTranslator<T,byte[]> - Parameters:
source- the source value to be translated- Returns:
- the target value
- Throws:
IOException- in case that translation fails
-
clone
Description copied from interface:SerializerCreates a new value instance and copies the values fromoriginto the new instance. Use theSerializerRegistryto implement cloning of nested object values.- Specified by:
clonein interfaceSerializer<T>- Parameters:
origin- the object to clone- Returns:
- the cloned object
- Throws:
IOException- in case that cloning/serialization operations fail
-
getType
Description copied from interface:SerializerThe type to be handled by this serializer.- Specified by:
getTypein interfaceSerializer<T>- Returns:
- the type
-