@Singleton public class JacksonObjectSerializer extends java.lang.Object implements ObjectSerializer
ObjectSerializer
interface for Jackson.JDK
Constructor and Description |
---|
JacksonObjectSerializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper) |
Modifier and Type | Method and Description |
---|---|
<T> java.util.Optional<T> |
deserialize(byte[] bytes,
Argument<T> requiredType)
Deserialize the given object to bytes.
|
<T> java.util.Optional<T> |
deserialize(byte[] bytes,
java.lang.Class<T> requiredType)
Deserialize the given object to bytes.
|
<T> java.util.Optional<T> |
deserialize(java.io.InputStream inputStream,
Argument<T> requiredType)
Deserialize the given object to bytes.
|
<T> java.util.Optional<T> |
deserialize(java.io.InputStream inputStream,
java.lang.Class<T> requiredType)
Deserialize the given object to bytes.
|
java.util.Optional<byte[]> |
serialize(java.lang.Object object)
Serialize the given object to a byte[].
|
void |
serialize(java.lang.Object object,
java.io.OutputStream outputStream)
Serialize the given object to a byte[].
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
deserialize
public JacksonObjectSerializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
objectMapper
- To read/write JSONpublic java.util.Optional<byte[]> serialize(java.lang.Object object) throws SerializationException
ObjectSerializer
serialize
in interface ObjectSerializer
object
- The object to serializeSerializationException
- if there is a serialization problempublic void serialize(java.lang.Object object, java.io.OutputStream outputStream) throws SerializationException
ObjectSerializer
serialize
in interface ObjectSerializer
object
- The object to serializeoutputStream
- The output streamSerializationException
- if there is a serialization problempublic <T> java.util.Optional<T> deserialize(byte[] bytes, java.lang.Class<T> requiredType) throws SerializationException
ObjectSerializer
deserialize
in interface ObjectSerializer
T
- The required generic typebytes
- The byte arrayrequiredType
- The required typeOptional
of the objectSerializationException
- if there is a serialization problempublic <T> java.util.Optional<T> deserialize(java.io.InputStream inputStream, java.lang.Class<T> requiredType) throws SerializationException
ObjectSerializer
deserialize
in interface ObjectSerializer
T
- The required generic typeinputStream
- The input streamrequiredType
- The required typeOptional
of the objectSerializationException
- if there is a serialization problempublic <T> java.util.Optional<T> deserialize(byte[] bytes, Argument<T> requiredType) throws SerializationException
ObjectSerializer
deserialize
in interface ObjectSerializer
T
- The required generic typebytes
- The byte arrayrequiredType
- The required typeOptional
of the objectSerializationException
- if there is a serialization problempublic <T> java.util.Optional<T> deserialize(java.io.InputStream inputStream, Argument<T> requiredType) throws SerializationException
ObjectSerializer
deserialize
in interface ObjectSerializer
T
- The required generic typeinputStream
- The input streamrequiredType
- The required typeOptional
of the objectSerializationException
- if there is a serialization problem