Package io.dapr.serializer
Class DefaultObjectSerializer
java.lang.Object
io.dapr.client.ObjectSerializer
io.dapr.serializer.DefaultObjectSerializer
- All Implemented Interfaces:
DaprObjectSerializer
Default serializer/deserializer for request/response objects and for state objects too.
-
Field Summary
Fields inherited from class io.dapr.client.ObjectSerializer
OBJECT_MAPPER
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<T> T
deserialize
(byte[] data, TypeRef<T> type) Deserializes the byte array into the original object.Returns the content type of the request.byte[]
Serializes a given state object into byte array.Methods inherited from class io.dapr.client.ObjectSerializer
deserialize, parseNode
-
Constructor Details
-
DefaultObjectSerializer
public DefaultObjectSerializer()
-
-
Method Details
-
serialize
Serializes a given state object into byte array.- Specified by:
serialize
in interfaceDaprObjectSerializer
- Overrides:
serialize
in classObjectSerializer
- Parameters:
o
- State object to be serialized.- Returns:
- Array of bytes[] with the serialized content.
- Throws:
IOException
- In case state cannot be serialized.
-
deserialize
Deserializes the byte array into the original object.- Specified by:
deserialize
in interfaceDaprObjectSerializer
- Overrides:
deserialize
in classObjectSerializer
- Type Parameters:
T
- Generic type of the object being deserialized.- Parameters:
data
- Content to be parsed.type
- Type of the object being deserialized.- Returns:
- Object of type T.
- Throws:
IOException
- In case content cannot be deserialized.
-
getContentType
Returns the content type of the request.- Specified by:
getContentType
in interfaceDaprObjectSerializer
- Returns:
- content type of the request
-