Package dev.restate.sdk.common
Interface Serde<T>
-
public interface Serde<T>Interface defining serialization and deserialization of concrete types.You can create a custom one using
using(String, ThrowingFunction, ThrowingFunction).
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default @Nullable java.lang.StringcontentType()Content-type to use in request/responses.Tdeserialize(byte[] value)default Tdeserialize(com.google.protobuf.ByteString byteString)byte[]serialize(@Nullable T value)default com.google.protobuf.ByteStringserializeToByteString(@Nullable T value)static <T> Serde<T>using(ThrowingFunction<T,byte[]> serializer, ThrowingFunction<byte[],T> deserializer)Likeusing(String, ThrowingFunction, ThrowingFunction), using content-typeapplication/octet-stream.static <T> Serde<T>using(java.lang.String contentType, ThrowingFunction<T,byte[]> serializer, ThrowingFunction<byte[],T> deserializer)static <T> Serde<T>withContentType(java.lang.String contentType, Serde<T> inner)
-
-
-
Method Detail
-
serialize
byte[] serialize(@Nullable T value)
-
serializeToByteString
default com.google.protobuf.ByteString serializeToByteString(@Nullable T value)
-
deserialize
T deserialize(byte[] value)
-
deserialize
default T deserialize(com.google.protobuf.ByteString byteString)
-
contentType
default @Nullable java.lang.String contentType()
Content-type to use in request/responses.If null, the SDK assumes the produced output is empty. This might change in the future.
-
using
static <T> Serde<T> using(ThrowingFunction<T,byte[]> serializer, ThrowingFunction<byte[],T> deserializer)
Likeusing(String, ThrowingFunction, ThrowingFunction), using content-typeapplication/octet-stream.
-
using
static <T> Serde<T> using(java.lang.String contentType, ThrowingFunction<T,byte[]> serializer, ThrowingFunction<byte[],T> deserializer)
Create aSerdefromserializer/deserializerlambdas, tagging withcontentType. Before invoking the serializer, we check thatvalueis non-null.
-
-