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.
|
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getIdentifier, getMetaData, getPayload, getPayloadType
public 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()
CommandMessage
getCommandName
in interface CommandMessage<T>
public GenericCommandMessage<T> withMetaData(Map<String,?> metaData)
CommandMessage
metaData
. 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)
CommandMessage
metaData
. The payload
remains unchanged.andMetaData
in interface CommandMessage<T>
andMetaData
in interface Message<T>
metaData
- The MetaData to merge withCopyright © 2010–2017. All rights reserved.