Class AvroConverter
- All Implemented Interfaces:
DescribableComponent,Converter
This converter is intended to work for classes, representing messages specified by Avro Schema. It is limited to
conversions specifying Class as a target type (and can not work on pure Type) definitions.
The conversion is delegated to the AvroConverterStrategy implementations. By default, the
SpecificRecordBaseConverterStrategy is provided and configured, to support Java classes generated by Avro
Maven plugin (delivered by Avro Java distribution). The AvroConverterConfiguration allows to register further
strategies. At least one strategy has to be configured for this converter to work.
- Since:
- 4.11.0
- Author:
- Simon Zambrovski, Jan Galinski
-
Constructor Summary
ConstructorsConstructorDescriptionAvroConverter(org.apache.avro.message.SchemaStore schemaStore, UnaryOperator<AvroConverterConfiguration> configurationOverride) Creates the converter instance.AvroConverter(org.apache.avro.message.SchemaStore schemaStore, UnaryOperator<AvroConverterConfiguration> configurationOverride, ChainingContentTypeConverter chainingTypeConverter) Creates the converter instance. -
Method Summary
Modifier and TypeMethodDescription<T> @Nullable TConverts the giveninputobject into an object of the giventargetType.voiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.
-
Constructor Details
-
AvroConverter
public AvroConverter(org.apache.avro.message.SchemaStore schemaStore, UnaryOperator<AvroConverterConfiguration> configurationOverride) Creates the converter instance.- Parameters:
schemaStore- schema store to use.configurationOverride- configuration customizer.
-
AvroConverter
@Internal public AvroConverter(org.apache.avro.message.SchemaStore schemaStore, UnaryOperator<AvroConverterConfiguration> configurationOverride, ChainingContentTypeConverter chainingTypeConverter) Creates the converter instance.- Parameters:
schemaStore- schema store to use.configurationOverride- configuration customizer.chainingTypeConverter- chaining type converter.
-
-
Method Details
-
convert
Description copied from interface:ConverterConverts the giveninputobject into an object of the giventargetType. -
describeTo
Description copied from interface:DescribableComponentDescribe the properties ofthis DescribableComponentwith the givendescriptor.Components should call the appropriate
describePropertymethods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.Best Practices: As a general rule, all relevant fields of a
DescribableComponentimplementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing thedescribeTomethod, who should focus on providing information that is useful for understanding the component's configuration and state.Example implementation:
public void describeTo(ComponentDescriptor descriptor) { descriptor.describeProperty("name", this.name); descriptor.describeProperty("enabled", this.enabled); descriptor.describeProperty("configuration", this.configuration); // A nested component descriptor.describeProperty("handlers", this.eventHandlers); // A collection }- Specified by:
describeToin interfaceDescribableComponent- Parameters:
descriptor- The component descriptor to describethis DescribableComponentn its properties in.
-