Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

P.S. Static method corresponding to ListSerde under org.apache.kafka.common.serialization.Serdes (something like static public Serde<List<T>> List() {...} in org.apache.kafka.common.serialization.Serdes) class cannot be added because type needs to be defined beforehand. That's why one needs to create List Serde in the following fashion:

new Serdes.ListSerde<String>(Serdes.String(), Comparator.comparing(String::length));

(can possibly be simplified by declaring import static org.apache.kafka.common.serialization.Serdes.ListSerde)

Proposed Changes

This KIP proposes adding new ListSerializer and ListDeserializer classes as well as support for the new classes into the Serdes class. This will allow using List<T> Serde directly from Consumers, Producers and Streams.

List<T> serialization and deserialization will be done through repeatedly calling a serializer/deserializer for each entry provided by passed generic T's Serde. For example, if you want to create List of Bytes Strings serde, you will have to declare `new Serdes.new ListSerde<>(Serdes.String(), Comparator.comparing(String::length))`, in this case serializer/deserializer of String Serde will be used to serialize/deserialize each entry in `List<String>`.

...