T - The type of payload contained in this Messagepublic class GenericCommandMessage<T> extends MessageDecorator<T> implements CommandMessage<T>
| Constructor and Description |
|---|
GenericCommandMessage(Message<T> delegate,
String commandName)
Create a CommandMessage from the given
delegate message containing payload, metadata and message
identifier, and the given commandName. |
GenericCommandMessage(T payload)
Create a CommandMessage with the given
command as payload and empty metaData |
GenericCommandMessage(T payload,
Map<String,?> metaData)
Create a CommandMessage with the given
command as payload. |
| Modifier and Type | Method and Description |
|---|---|
GenericCommandMessage<T> |
andMetaData(Map<String,?> metaData)
Returns a copy of this CommandMessage with it MetaData merged with the given
metaData. |
static <C> CommandMessage<C> |
asCommandMessage(Object command)
Returns the given command as a CommandMessage.
|
protected void |
describeTo(StringBuilder stringBuilder)
Describe the message specific properties to the given
stringBuilder. |
protected String |
describeType()
Describe the type of message, used in
MessageDecorator.toString(). |
String |
getCommandName()
Returns the name of the command to execute.
|
GenericCommandMessage<T> |
withMetaData(Map<String,?> metaData)
Returns a copy of this CommandMessage with the given
metaData. |
getDelegate, getIdentifier, getMetaData, getPayload, getPayloadType, serializeMetaData, serializePayload, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetIdentifier, getMetaData, getPayload, getPayloadType, serializeMetaData, serializePayloadpublic GenericCommandMessage(T payload)
command as payload and empty metaDatapayload - the payload for the Messagepublic GenericCommandMessage(T payload, Map<String,?> metaData)
command as payload.payload - the payload for the MessagemetaData - The meta data for this messagepublic GenericCommandMessage(Message<T> delegate, String commandName)
delegate message containing payload, metadata and message
identifier, and the given commandName.delegate - the delegate messagecommandName - The name of the commandpublic static <C> CommandMessage<C> asCommandMessage(Object command)
command already implements CommandMessage, it is
returned as-is. Otherwise, the given command is wrapped into a GenericCommandMessage as its
payload.command - the command to wrap as CommandMessagecommand as payload, or command if it already implements
CommandMessage.public String getCommandName()
CommandMessagegetCommandName in interface CommandMessage<T>public GenericCommandMessage<T> withMetaData(Map<String,?> metaData)
CommandMessagemetaData. The payload remains unchanged.
While the implementation returned may be different than the implementation of this, implementations
must take special care in returning the same type of Message (e.g. EventMessage, DomainEventMessage) to prevent
errors further downstream.withMetaData in interface CommandMessage<T>withMetaData in interface Message<T>metaData - The new MetaData for the Messagepublic GenericCommandMessage<T> andMetaData(Map<String,?> metaData)
CommandMessagemetaData. The payload
remains unchanged.andMetaData in interface CommandMessage<T>andMetaData in interface Message<T>metaData - The MetaData to merge withprotected void describeTo(StringBuilder stringBuilder)
MessageDecoratorstringBuilder. 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.
describeTo in class MessageDecorator<T>stringBuilder - the builder to append data toprotected String describeType()
MessageDecoratorMessageDecorator.toString().
Defaults to the simple class name of the actual instance.
describeType in class MessageDecorator<T>Copyright © 2010–2020. All rights reserved.