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 TypeMethodDescriptionbooleancanConvert(Type sourceType, Type targetType) Indicates whether thisConverteris capable of converting the givensourceTypeto thetargetType.<T> TConverts the giveninputobject into an object of the giventargetType.voiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.conversion.Converter
canConvert, convert
-
Constructor Details
-
AvroConverter
public AvroConverter(@Nonnull org.apache.avro.message.SchemaStore schemaStore, @Nonnull UnaryOperator<AvroConverterConfiguration> configurationOverride) Creates the converter instance.- Parameters:
schemaStore- schema store to use.configurationOverride- configuration customizer.
-
AvroConverter
@Internal public AvroConverter(@Nonnull org.apache.avro.message.SchemaStore schemaStore, @Nonnull UnaryOperator<AvroConverterConfiguration> configurationOverride, @Nonnull ChainingContentTypeConverter chainingTypeConverter) Creates the converter instance.- Parameters:
schemaStore- schema store to use.configurationOverride- configuration customizer.chainingTypeConverter- chaining type converter.
-
-
Method Details
-
canConvert
Description copied from interface:ConverterIndicates whether thisConverteris capable of converting the givensourceTypeto thetargetType.- Specified by:
canConvertin interfaceConverter- Parameters:
sourceType- The type of data to convert from.targetType- The type of data to convert to.- Returns:
trueif conversion is possible,falseotherwise.
-
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.
-