Interface Serde<T>


public interface Serde<T>
Interface defining serialization and deserialization of concrete types.

Serde implementations are provided in JsonSerdes in sdk-api, KtSerdes in sdk-api-kotlin, JacksonSerdes in sdk-serde-jackson, ProtobufSerdes in sdk-serde-protobuf.

You can create a custom one using using(String, ThrowingFunction, ThrowingFunction).

  • Field Details

  • Method Details

    • serialize

      byte[] serialize(@Nullable T value)
    • serializeToByteBuffer

      default ByteBuffer serializeToByteBuffer(@Nullable T value)
    • deserialize

      T deserialize(byte[] value)
    • deserialize

      default T deserialize(ByteBuffer byteBuffer)
    • contentType

      default @Nullable 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)
      Like using(String, ThrowingFunction, ThrowingFunction), using content-type application/octet-stream.
    • using

      static <T> Serde<T> using(String contentType, ThrowingFunction<T,byte[]> serializer, ThrowingFunction<byte[],T> deserializer)
      Create a Serde from serializer/deserializer lambdas, tagging with contentType. Before invoking the serializer, we check that value is non-null.
    • withContentType

      static <T> Serde<T> withContentType(String contentType, Serde<T> inner)