Class EncoderDecoder.ChainedEnDec

java.lang.Object
io.aiven.kafka.connect.amqp.common.data.EncoderDecoder
io.aiven.kafka.connect.amqp.common.data.EncoderDecoder.ChainedEnDec
Enclosing class:
EncoderDecoder

public static final class EncoderDecoder.ChainedEnDec extends EncoderDecoder
A EncoderDecoder that chains multiple converters together. When encode(Object) or decode(SchemaAndValue) is called the converters are called in chain order. The first non-empty Optional (if any) is returned.
  • Constructor Details

    • ChainedEnDec

      public ChainedEnDec(EncoderDecoder... converters)
      Constructs a chain of converters.
      Parameters:
      converters - the chain of converters to use. Order is preserved.
  • Method Details

    • encode

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

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

      protected void setSelf(EncoderDecoder newConverter)
      Description copied from class: EncoderDecoder
      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.
      Overrides:
      setSelf in class EncoderDecoder
      Parameters:
      newConverter - the converter against which recursive calls should be made.
    • toString

      public String toString()
      Overrides:
      toString in class EncoderDecoder