Class EncoderDecoder
java.lang.Object
io.aiven.kafka.connect.amqp.common.data.EncoderDecoder
- Direct Known Subclasses:
AmqpEnDec,CollectionEnDec,EncoderDecoder.ChainedEnDec,KafkaEnDec,UniqueTypeEnDec
Abstract class to encode objects as SchemaAndValue objects and to decode SchemaAndValue object
into Objects.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA EncoderDecoder that chains multiple converters together. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal EncoderDecoderandThen(EncoderDecoder nextConverter) Creates a chained converter where thenextConverteris called if this converter can not encode/decode a value.decode(org.apache.kafka.connect.data.SchemaAndValue schemaAndValue) Decodes a SchemaAndValue into an object.abstract Optional<org.apache.kafka.connect.data.SchemaAndValue>Encodes thevalueas a SchemaAndValue.protected final EncoderDecoderself()A reference to this converter.protected voidsetSelf(EncoderDecoder converter) A method to set the EncoderDecoder against which recursive calls should be made.toString()
-
Constructor Details
-
EncoderDecoder
protected EncoderDecoder()Default constructor.
-
-
Method Details
-
encode
Encodes thevalueas a SchemaAndValue. If this converter can not perform the encoding it returns an emptyOptional.- 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 emptyOptional.- Parameters:
schemaAndValue- the schema and value to decode.- Returns:
- the Optional Object or an empty Optional if not decoded.
-
self
A reference to this converter. Theself()method is used so that when Converters are chained together it is possible for a lower level EncoderDecoder to recursively callencode(Object)ordecode(SchemaAndValue).- Returns:
- the EncoderDecoder against which recursive calls should be made.
-
setSelf
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 aEncoderDecoder.ChainedEnDec.- Parameters:
converter- the converter against which recursive calls should be made.
-
toString
-
andThen
Creates a chained converter where thenextConverteris 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.ChainedEnDeccomprised of this converter and the @{code nextConverter}.
-