Class MessageDecorator
- All Implemented Interfaces:
Message
- Direct Known Subclasses:
GenericCommandMessage,GenericEventMessage,GenericQueryMessage,GenericResetContext,GenericResultMessage
Message that delegates to an existing message.
Extend this decorator class to extend the message with additional features.
- Since:
- 3.0.0
- Author:
- Steven van Beelen, Rene de Waele
-
Field Summary
Fields inherited from interface org.axonframework.messaging.core.Message
RESOURCE_KEY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMessageDecorator(Message delegate) Initializes a new decorator with givendelegateMessage. -
Method Summary
Modifier and TypeMethodDescriptionprotected Messagedelegate()Returns the wrappedMessagedelegated by this decorator.protected voiddescribeTo(StringBuilder stringBuilder) Describe the message specific properties to the givenstringBuilder.protected StringDescribe the type of message, used intoString().Returns the identifier of thisMessage.metadata()Returns theMetadatafor thisMessage.payload()Returns the payload of thisMessage.<T> TReturns the payload of thisMessage, converted to the giventypeby the givenconverter.Class<?> Returns the type of the payload.toString()type()Returns the messagetypeof thisMessage.withConvertedPayload(Type type, Converter converter) Returns a newMessageimplementation with itsMessage.payload()converted to the giventypeby the givenconverter.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.axonframework.messaging.core.Message
andMetadata, payloadAs, payloadAs, payloadAs, payloadAs, withConvertedPayload, withConvertedPayload, withMetadata
-
Constructor Details
-
Method Details
-
identifier
Description copied from interface:MessageReturns the identifier of thisMessage.Two messages with the same identifiers should be interpreted as different representations of the same conceptual message. In such case, the
metadatamay be different for both representations. Thepayloadmay be identical.- Specified by:
identifierin interfaceMessage- Returns:
- The unique identifier of this
Message.
-
type
Description copied from interface:MessageReturns the messagetypeof thisMessage. -
payload
Description copied from interface:MessageReturns the payload of thisMessage.The payload is the application-specific information.
-
payloadAs
Description copied from interface:MessageReturns the payload of thisMessage, converted to the giventypeby the givenconverter.If the given
typeis an instance ofClassandMessage.payloadType()isassignable fromthatClass,Message.payload()may be invoked instead of using the givenconverter.Implementers of this operation may optimize by storing the converted payloads, thus saving a
Converter.convert(Object, Class)invocation in the process. Only when this optimization is in place will anull converterresult in a successful invocation of this method.- Specified by:
payloadAsin interfaceMessage- Type Parameters:
T- The generic type to convert thisMessage'spayload to.- Parameters:
type- The type to convert thisMessage'spayload to.converter- The converter to convert thisMessage'spayload with.- Returns:
- The payload of this
Message, converted to the giventype.
-
payloadType
Description copied from interface:MessageReturns the type of the payload.Is semantically equal to
getPayload().getClass(), but allows implementations to optimize by using lazy loading or deserialization.- Specified by:
payloadTypein interfaceMessage- Returns:
- The type of payload.
-
metadata
Description copied from interface:Message -
withConvertedPayload
Description copied from interface:MessageReturns a newMessageimplementation with itsMessage.payload()converted to the giventypeby the givenconverter. This newMessageis effectively a copy ofthis Messagewith a renewed payload andMessage.payloadType().Will return the
thisinstance if thepayload typeisassignable fromthe converted result.- Specified by:
withConvertedPayloadin interfaceMessage- Parameters:
type- The type to convert theMessage.payload()to.converter- The converter to convert theMessage.payload()with.- Returns:
- A new
Messageimplementation with itsMessage.payload()converted to the giventypeby the givenconverter.
-
delegate
Returns the wrappedMessagedelegated by this decorator.- Returns:
- The wrapped
Messagedelegated by this decorator.
-
toString
-
describeTo
Describe the message specific properties to the givenstringBuilder. Subclasses should override this method, calling the super method and appending their own properties to the end (or beginning).As convention, String values should be enclosed in single quotes, Objects in curly brackets and numeric values may be appended without enclosing. All properties should be preceded by a comma when appending, or finish with a comma when prefixing values.
- Parameters:
stringBuilder- The builder to append data to.
-
describeType
Describe the type of message, used intoString().Defaults to the simple class name of the actual instance.
- Returns:
- The type of the message.
-