Interface Serializer<T>

Type Parameters:
T - Type to be serialized from.
All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
ByteArraySerializer, ByteBufferSerializer, BytesSerializer, DoubleSerializer, FloatSerializer, IntegerSerializer, ListSerializer, LongSerializer, SessionWindowedSerializer, ShortSerializer, StringSerializer, TimeWindowedSerializer, UUIDSerializer, VoidSerializer

public interface Serializer<T>
extends Closeable
An interface for converting objects to bytes. A class that implements this interface is expected to have a constructor with no parameter.

Implement ClusterResourceListener to receive cluster metadata once it's available. Please see the class documentation for ClusterResourceListener for more information.

  • Method Summary

    Modifier and Type Method Description
    default void close()
    Close this serializer.
    default void configure​(Map<String,​?> configs, boolean isKey)
    Configure this class.
    default byte[] serialize​(String topic, Headers headers, T data)
    Convert data into a byte array.
    byte[] serialize​(String topic, T data)
    Convert data into a byte array.
  • Method Details

    • configure

      default void configure​(Map<String,​?> configs, boolean isKey)
      Configure this class.
      Parameters:
      configs - configs in key/value pairs
      isKey - whether is for key or value
    • serialize

      byte[] serialize​(String topic, T data)
      Convert data into a byte array.
      Parameters:
      topic - topic associated with data
      data - typed data
      Returns:
      serialized bytes
    • serialize

      default byte[] serialize​(String topic, Headers headers, T data)
      Convert data into a byte array.
      Parameters:
      topic - topic associated with data
      headers - headers associated with the record
      data - typed data
      Returns:
      serialized bytes
    • close

      default void close()
      Close this serializer.

      This method must be idempotent as it may be called multiple times.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable