Class EncoderDecoder

java.lang.Object
io.aiven.kafka.connect.amqp.common.data.EncoderDecoder
Direct Known Subclasses:
AmqpEnDec, CollectionEnDec, EncoderDecoder.ChainedEnDec, KafkaEnDec, UniqueTypeEnDec

public abstract class EncoderDecoder extends Object
Abstract class to encode objects as SchemaAndValue objects and to decode SchemaAndValue object into Objects.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    A EncoderDecoder that chains multiple converters together.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Default constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    andThen(EncoderDecoder nextConverter)
    Creates a chained converter where the nextConverter is called if this converter can not encode/decode a value.
    abstract Optional<Object>
    decode(org.apache.kafka.connect.data.SchemaAndValue schemaAndValue)
    Decodes a SchemaAndValue into an object.
    abstract Optional<org.apache.kafka.connect.data.SchemaAndValue>
    encode(Object value)
    Encodes the value as a SchemaAndValue.
    protected final EncoderDecoder
    A reference to this converter.
    protected void
    A method to set the EncoderDecoder against which recursive calls should be made.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • EncoderDecoder

      protected EncoderDecoder()
      Default constructor.
  • Method Details

    • encode

      public abstract Optional<org.apache.kafka.connect.data.SchemaAndValue> encode(Object value)
      Encodes the value as a SchemaAndValue. If this converter can not perform the encoding it returns an empty Optional.
      Parameters:
      value - the value to convert.
      Returns:
      the Optional SchemaAndValue or an empty Optional.
    • decode

      public abstract Optional<Object> decode(org.apache.kafka.connect.data.SchemaAndValue schemaAndValue)
      Decodes a SchemaAndValue into an object. If this converter can not perform the decoding it returns an empty Optional.
      Parameters:
      schemaAndValue - the schema and value to decode.
      Returns:
      the Optional Object or an empty Optional if not decoded.
    • self

      protected final EncoderDecoder self()
      A reference to this converter. The self() method is used so that when Converters are chained together it is possible for a lower level EncoderDecoder to recursively call encode(Object) or decode(SchemaAndValue).
      Returns:
      the EncoderDecoder against which recursive calls should be made.
    • setSelf

      protected void setSelf(EncoderDecoder converter)
      A method to set the EncoderDecoder against which recursive calls should be made. In most cases this will not be called except when the converter is used in a EncoderDecoder.ChainedEnDec.
      Parameters:
      converter - the converter against which recursive calls should be made.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • andThen

      public final EncoderDecoder andThen(EncoderDecoder nextConverter)
      Creates a chained converter where the nextConverter is called if this converter can not encode/decode a value.
      Parameters:
      nextConverter - the converter to call if this converter can not encode/decode a value.
      Returns:
      a new EncoderDecoder.ChainedEnDec comprised of this converter and the @{code nextConverter}.