Interface Serde<T extends @Nullable Object>

All Known Subinterfaces:
RichSerde<T>

@NullMarked public interface Serde<T extends @Nullable Object>
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(T value)
    • serializeToByteBuffer

      default ByteBuffer serializeToByteBuffer(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 extends @NonNull Object> Serde<@NonNull T> using(ThrowingFunction<T,byte[]> serializer, ThrowingFunction<byte[],T> deserializer)
      Like using(String, ThrowingFunction, ThrowingFunction), using content-type application/octet-stream.
    • using

      static <T extends @NonNull Object> Serde<@NonNull 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)