Class GenericCommandMessage<T>
java.lang.Object
org.axonframework.messaging.MessageDecorator<T>
org.axonframework.commandhandling.GenericCommandMessage<T>
- Type Parameters:
T- The type of payload contained in this Message
- All Implemented Interfaces:
Serializable,CommandMessage<T>,Message<T>
Implementation of the CommandMessage that takes all properties as constructor parameters.
- Since:
- 2.0
- Author:
- Allard Buijze
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionGenericCommandMessage(Message<T> delegate, String commandName) Create a CommandMessage from the givendelegatemessage containing payload, metadata and message identifier, and the givencommandName.GenericCommandMessage(T payload) Create a CommandMessage with the givencommandas payload and empty metaDataGenericCommandMessage(T payload, Map<String, ?> metaData) Create a CommandMessage with the givencommandas payload. -
Method Summary
Modifier and TypeMethodDescriptionandMetaData(Map<String, ?> metaData) Returns a copy of this CommandMessage with it MetaData merged with the givenmetaData.static <C> CommandMessage<C> asCommandMessage(Object command) Returns the given command as aCommandMessage.protected voiddescribeTo(StringBuilder stringBuilder) Describe the message specific properties to the givenstringBuilder.protected StringDescribe the type of message, used inMessageDecorator.toString().Returns the name of the command to execute.withMetaData(Map<String, ?> metaData) Returns a copy of this CommandMessage with the givenmetaData.Methods inherited from class org.axonframework.messaging.MessageDecorator
getDelegate, getIdentifier, getMetaData, getPayload, getPayloadType, serializeMetaData, serializePayload, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.axonframework.messaging.Message
getIdentifier, getMetaData, getPayload, getPayloadType, serializeMetaData, serializePayload
-
Constructor Details
-
GenericCommandMessage
Create a CommandMessage with the givencommandas payload and empty metaData- Parameters:
payload- the payload for the Message
-
GenericCommandMessage
Create a CommandMessage with the givencommandas payload.- Parameters:
payload- the payload for the MessagemetaData- The meta data for this message
-
GenericCommandMessage
Create a CommandMessage from the givendelegatemessage containing payload, metadata and message identifier, and the givencommandName.- Parameters:
delegate- the delegate messagecommandName- The name of the command
-
-
Method Details
-
asCommandMessage
Returns the given command as aCommandMessage. Ifcommandalready implementsCommandMessage, it is returned as-is. When thecommandis another implementation ofMessage, theMessage.getPayload()andMessage.getMetaData()are used as input for a newGenericCommandMessage. Otherwise, the givencommandis wrapped into aGenericCommandMessageas its payload.- Parameters:
command- The command to wrap asCommandMessage.- Returns:
- A
CommandMessagecontaining givencommandas payload, acommandif it already implementsCommandMessage, or aCommandMessagebased on the result ofMessage.getPayload()andMessage.getMetaData()for otherMessageimplementations.
-
getCommandName
Description copied from interface:CommandMessageReturns the name of the command to execute. This is an indication of what should be done, using the payload as parameter.- Specified by:
getCommandNamein interfaceCommandMessage<T>- Returns:
- the name of the command
-
withMetaData
Description copied from interface:CommandMessageReturns a copy of this CommandMessage with the givenmetaData. The payload remains unchanged. While the implementation returned may be different than the implementation ofthis, implementations must take special care in returning the same type of Message (e.g. EventMessage, DomainEventMessage) to prevent errors further downstream.- Specified by:
withMetaDatain interfaceCommandMessage<T>- Specified by:
withMetaDatain interfaceMessage<T>- Parameters:
metaData- The new MetaData for the Message- Returns:
- a copy of this message with the given MetaData
-
andMetaData
Description copied from interface:CommandMessageReturns a copy of this CommandMessage with it MetaData merged with the givenmetaData. The payload remains unchanged.- Specified by:
andMetaDatain interfaceCommandMessage<T>- Specified by:
andMetaDatain interfaceMessage<T>- Parameters:
metaData- The MetaData to merge with- Returns:
- a copy of this message with the given MetaData
-
describeTo
Description copied from class:MessageDecoratorDescribe 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.
- Overrides:
describeToin classMessageDecorator<T>- Parameters:
stringBuilder- the builder to append data to
-
describeType
Description copied from class:MessageDecoratorDescribe the type of message, used inMessageDecorator.toString().Defaults to the simple class name of the actual instance.
- Overrides:
describeTypein classMessageDecorator<T>- Returns:
- the type of message
-