public class ObjectSerializer extends Object
Modifier and Type | Field and Description |
---|---|
protected static com.fasterxml.jackson.databind.ObjectMapper |
OBJECT_MAPPER
Shared Json serializer/deserializer as per Jackson's documentation.
|
Modifier | Constructor and Description |
---|---|
protected |
ObjectSerializer()
Default constructor to avoid class from being instantiated outside package but still inherited.
|
Modifier and Type | Method and Description |
---|---|
<T> T |
deserialize(byte[] content,
Class<T> clazz)
Deserializes the byte array into the original object.
|
byte[] |
serialize(Object state)
Serializes a given state object into byte array.
|
protected static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER
protected ObjectSerializer()
public byte[] serialize(Object state) throws IOException
state
- State object to be serialized.IOException
- In case state cannot be serialized.public <T> T deserialize(byte[] content, Class<T> clazz) throws IOException
T
- Generic type of the object being deserialized.content
- Content to be parsed.clazz
- Type of the object being deserialized.IOException
- In case content cannot be deserialized.Copyright © 2020. All rights reserved.