Package io.dapr.client
Class ObjectSerializer
- java.lang.Object
-
- io.dapr.client.ObjectSerializer
-
- Direct Known Subclasses:
ActorObjectSerializer
,DefaultObjectSerializer
public class ObjectSerializer extends Object
Serializes and deserializes an internal object.
-
-
Field Summary
Fields Modifier and Type Field Description protected static com.fasterxml.jackson.databind.ObjectMapper
OBJECT_MAPPER
Shared Json serializer/deserializer as per Jackson's documentation.
-
Constructor Summary
Constructors Modifier Constructor Description protected
ObjectSerializer()
Default constructor to avoid class from being instantiated outside package but still inherited.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
deserialize(byte[] content, TypeRef<T> type)
Deserializes the byte array into the original object.<T> T
deserialize(byte[] content, Class<T> clazz)
Deserializes the byte array into the original object.com.fasterxml.jackson.databind.JsonNode
parseNode(byte[] content)
Parses the JSON content into a node for fine-grained processing.byte[]
serialize(Object state)
Serializes a given state object into byte array.
-
-
-
Method Detail
-
serialize
public byte[] serialize(Object state) throws IOException
Serializes a given state object into byte array.- Parameters:
state
- State object to be serialized.- Returns:
- Array of bytes[] with the serialized content.
- Throws:
IOException
- In case state cannot be serialized.
-
deserialize
public <T> T deserialize(byte[] content, TypeRef<T> type) throws IOException
Deserializes the byte array into the original object.- Type Parameters:
T
- Generic type of the object being deserialized.- Parameters:
content
- Content to be parsed.type
- Type of the object being deserialized.- Returns:
- Object of type T.
- Throws:
IOException
- In case content cannot be deserialized.
-
deserialize
public <T> T deserialize(byte[] content, Class<T> clazz) throws IOException
Deserializes the byte array into the original object.- Type Parameters:
T
- Generic type of the object being deserialized.- Parameters:
content
- Content to be parsed.clazz
- Type of the object being deserialized.- Returns:
- Object of type T.
- Throws:
IOException
- In case content cannot be deserialized.
-
parseNode
public com.fasterxml.jackson.databind.JsonNode parseNode(byte[] content) throws IOException
Parses the JSON content into a node for fine-grained processing.- Parameters:
content
- JSON content.- Returns:
- JsonNode.
- Throws:
IOException
- In case content cannot be parsed.
-
-