Interface Serializer<T>
- Type Parameters:
T
- Type to be serialized from.
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Implementing Classes:
BooleanSerializer
,ByteArraySerializer
,ByteBufferSerializer
,BytesSerializer
,DoubleSerializer
,FloatSerializer
,IntegerSerializer
,ListSerializer
,LongSerializer
,SessionWindowedSerializer
,ShortSerializer
,StringSerializer
,TimeWindowedSerializer
,UUIDSerializer
,VoidSerializer
This interface can be combined with ClusterResourceListener
to receive cluster metadata once it's available, as well as Monitorable
to enable the serializer to register metrics. For the latter, the following tags are automatically added to all
metrics registered: config
set to either key.serializer
or value.serializer
,
and class
set to the serializer class name.
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
close()
Close this serializer.default void
Configure this class.default byte[]
Convertdata
into a byte array.byte[]
Convertdata
into a byte array.
-
Method Details
-
configure
Configure this class.- Parameters:
configs
- configs in key/value pairsisKey
- whether the serializer is used for the key or the value
-
serialize
Convertdata
into a byte array.It is recommended to serialize
null
data to thenull
byte array.- Parameters:
topic
- topic associated with datadata
- typed data; may benull
- Returns:
- serialized bytes; may be
null
-
serialize
Convertdata
into a byte array.It is recommended to serialize
null
data to thenull
byte array.Note that the passed in
Headers
may be empty, but nevernull
. The implementation is allowed to modify the passed in headers, as a side effect of serialization. It is considered best practice to not delete or modify existing headers, but rather only add new ones.- Parameters:
topic
- topic associated with dataheaders
- headers associated with the recorddata
- typed data; may benull
- Returns:
- serialized bytes; may be
null
-
close
default void close()Close this serializer.This method must be idempotent as it may be called multiple times.
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-