Class DelegatingEventConverter
- All Implemented Interfaces:
DescribableComponent,Converter,EventConverter
EventConverter implementation delegating conversion operations to a MessageConverter.
Useful to ensure callers of this component only convert EventMessage implementations.
- Since:
- 5.0.0
- Author:
- Steven van Beelen
-
Constructor Summary
ConstructorsConstructorDescriptionDelegatingEventConverter(Converter converter) Constructs aDelegatingEventConverter, delegating operations to aDelegatingMessageConverterbuild with the givenconverter.DelegatingEventConverter(MessageConverter delegate) Constructs aDelegatingEventConverter, 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.<E extends EventMessage>
EconvertEvent(E event, Type targetType) Converts the givenevent'spayloadto the giventargetType, returning a newEventMessagewith the converted payload.<E extends EventMessage,T>
TconvertPayload(E event, Type targetType) delegate()Returns theMessageConverterthisEventConverterdelegates 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.eventhandling.conversion.EventConverter
convertEvent, convertPayload
-
Constructor Details
-
DelegatingEventConverter
Constructs aDelegatingEventConverter, delegating operations to aDelegatingMessageConverterbuild with the givenconverter.- Parameters:
converter- The converter to construct aDelegatingMessageConverterwith to delegate all conversion operations to.
-
DelegatingEventConverter
Constructs aDelegatingEventConverter, 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 <E extends EventMessage,T> T convertPayload(@Nonnull E event, @Nonnull Type targetType) Description copied from interface:EventConverter- Specified by:
convertPayloadin interfaceEventConverter- Type Parameters:
E- The type ofEventMessageto convert the payload for.T- The target data type.- Parameters:
event- TheEventMessageto convert thepayloadfor.targetType- The type to convert thepayloadinto.- Returns:
- A converted version of the given
EventMessage'spayloadinto the giventargetType.
-
convertEvent
Description copied from interface:EventConverterConverts the givenevent'spayloadto the giventargetType, returning a newEventMessagewith the converted payload.- Specified by:
convertEventin interfaceEventConverter- Type Parameters:
E- The type ofEventMessageto convert and return.- Parameters:
event- TheEventMessageto convert thepayloadfor.targetType- The type to convert thepayloadinto.- Returns:
- A new
EventMessagecontaining the converted version of the givenevent'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 theMessageConverterthisEventConverterdelegates to.Useful to construct other instances with the exact same
Converter.- Returns:
- The
MessageConverterthisEventConverterdelegates to.
-