Class PassThroughConverter
- All Implemented Interfaces:
DescribableComponent,Converter
Converter implementation that only "passes through" input object if the sourceType and
targetType are the identical.
As such, no conversion is performed by this Converter! The Converter.canConvert(Class, Class) operation will
only return true whenever both types are identical. Furthermore, both Converter.convert(Object, Class)
and convert(Object, Type) will expect identical typing too, otherwise resulting in an
IllegalArgumentException.
As such, this Converter is only useful when conversion is not necessary (e.g. during testing) for the
component at hand.
- Since:
- 5.0.0
- Author:
- Mateusz Nowak
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PassThroughConverterThe single instance of thePassThroughConverter. -
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
-
Field Details
-
INSTANCE
The single instance of thePassThroughConverter.
-
-
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.
-