Class JsonObjectSerde<T>

java.lang.Object
io.micronaut.configuration.kafka.serde.JsonObjectSerde<T>
Type Parameters:
T - The type to serialize/deserialize
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.kafka.common.serialization.Deserializer<T>, org.apache.kafka.common.serialization.Serde<T>, org.apache.kafka.common.serialization.Serializer<T>

@Prototype public class JsonObjectSerde<T> extends Object implements org.apache.kafka.common.serialization.Serializer<T>, org.apache.kafka.common.serialization.Deserializer<T>, org.apache.kafka.common.serialization.Serde<T>
A Serializer and Deserializer for JSON.
Since:
4.1.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    JsonObjectSerde(io.micronaut.json.JsonObjectSerializer objectSerializer, Class<T> type)
    Constructs a new instance for the given arguments.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    configure(Map<String,?> configs, boolean isKey)
     
    deserialize(String topic, byte[] data)
     
    org.apache.kafka.common.serialization.Deserializer<T>
     
    byte[]
    serialize(String topic, T data)
     
    org.apache.kafka.common.serialization.Serializer<T>
     
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.apache.kafka.common.serialization.Deserializer

    deserialize, deserialize

    Methods inherited from interface org.apache.kafka.common.serialization.Serializer

    serialize
  • Constructor Details

    • JsonObjectSerde

      @Creator public JsonObjectSerde(io.micronaut.json.JsonObjectSerializer objectSerializer, @Parameter Class<T> type)
      Constructs a new instance for the given arguments.
      Parameters:
      objectSerializer - The JsonObjectSerializer
      type - The target type
  • Method Details

    • deserialize

      public T deserialize(String topic, byte[] data)
      Specified by:
      deserialize in interface org.apache.kafka.common.serialization.Deserializer<T>
    • configure

      public void configure(Map<String,?> configs, boolean isKey)
      Specified by:
      configure in interface org.apache.kafka.common.serialization.Deserializer<T>
      Specified by:
      configure in interface org.apache.kafka.common.serialization.Serde<T>
      Specified by:
      configure in interface org.apache.kafka.common.serialization.Serializer<T>
    • serialize

      public byte[] serialize(String topic, T data)
      Specified by:
      serialize in interface org.apache.kafka.common.serialization.Serializer<T>
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface org.apache.kafka.common.serialization.Deserializer<T>
      Specified by:
      close in interface org.apache.kafka.common.serialization.Serde<T>
      Specified by:
      close in interface org.apache.kafka.common.serialization.Serializer<T>
    • serializer

      public org.apache.kafka.common.serialization.Serializer<T> serializer()
      Specified by:
      serializer in interface org.apache.kafka.common.serialization.Serde<T>
    • deserializer

      public org.apache.kafka.common.serialization.Deserializer<T> deserializer()
      Specified by:
      deserializer in interface org.apache.kafka.common.serialization.Serde<T>
    • toString

      public String toString()
      Overrides:
      toString in class Object