Class DelegatingMessageConverter
- All Implemented Interfaces:
DescribableComponent,Converter,MessageConverter
MessageConverter implementation delegating conversion operations to a Converter.
Useful to ensure callers of this component only convert Message implementations.
- Since:
- 5.0.0
- Author:
- Steven van Beelen
-
Constructor Summary
ConstructorsConstructorDescriptionDelegatingMessageConverter(Converter delegate) Constructs aDelegatingMessageConverter, delegating operations to the givenconverter. -
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.<M extends Message>
MconvertMessage(M message, Type targetType) Converts the givenmessage'spayloadto the giventargetType, returning a newMessagewith the converted payload.<M extends Message,T>
TconvertPayload(M message, Type targetType) delegate()Returns the delegateConverterthisMessageConverterdelegates to.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, convertMethods inherited from interface org.axonframework.messaging.core.conversion.MessageConverter
convertMessage, convertPayload
-
Constructor Details
-
DelegatingMessageConverter
Constructs aDelegatingMessageConverter, delegating operations to the givenconverter.- Parameters:
delegate- The converter to delegate all conversion operations to.
-
-
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. -
convertPayload
@Nullable public <M extends Message,T> T convertPayload(@Nonnull M message, @Nonnull Type targetType) Description copied from interface:MessageConverter- Specified by:
convertPayloadin interfaceMessageConverter- Type Parameters:
M- The type ofMessageto convert the payload for.T- The target data type.- Parameters:
message- TheMessageto convert thepayloadfor.targetType- The type to convert thepayloadinto.- Returns:
- A converted version of the given
Message'spayloadinto the giventargetType.
-
convertMessage
Description copied from interface:MessageConverterConverts the givenmessage'spayloadto the giventargetType, returning a newMessagewith the converted payload.- Specified by:
convertMessagein interfaceMessageConverter- Type Parameters:
M- The type ofMessageto convert and return.- Parameters:
message- TheMessageto convert thepayloadfor.targetType- The type to convert thepayloadinto.- Returns:
- A new
Messagecontaining the converted version of the givenmessage'spayloadinto 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.
-
delegate
Returns the delegateConverterthisMessageConverterdelegates to.Useful to construct other instances with the exact same
Converter.- Returns:
- The
ConverterthisMessageConverterdelegates to.
-