T - The type of payload contained in this Messagepublic class GenericCommandMessage<T> extends Object implements CommandMessage<T>
| Modifier | Constructor and Description |
|---|---|
protected |
GenericCommandMessage(GenericCommandMessage<T> original,
Map<String,?> metaData)
Copy constructor that allows creation of a new GenericCommandMessage with modified metaData.
|
|
GenericCommandMessage(String identifier,
String commandName,
T payload,
Map<String,?> newMetaData)
Create a CommandMessage with the given
command as payload and a custom chosen
identifier. |
|
GenericCommandMessage(String commandName,
T payload,
Map<String,?> newMetaData)
Create a CommandMessage with the given
command as payload. |
|
GenericCommandMessage(T payload)
Create a CommandMessage with the given
command as payload and empty metaData |
|
GenericCommandMessage(T payload,
Map<String,?> newMetaData)
Create a CommandMessage with the given
command as payload. |
| Modifier and Type | Method and Description |
|---|---|
GenericCommandMessage<T> |
andMetaData(Map<String,?> additionalMetaData)
Returns a copy of this CommandMessage with it MetaData merged with the given
metaData. |
static CommandMessage |
asCommandMessage(Object command)
Returns the given command as a CommandMessage.
|
String |
getCommandName()
Returns the name of the command to execute.
|
String |
getIdentifier()
Returns the identifier of this message.
|
MetaData |
getMetaData()
Returns the meta data for this event.
|
T |
getPayload()
Returns the payload of this Event.
|
Class |
getPayloadType()
Returns the type of the payload.
|
GenericCommandMessage<T> |
withMetaData(Map<String,?> newMetaData)
Returns a copy of this CommandMessage with the given
metaData. |
public GenericCommandMessage(T payload)
command as payload and empty metaDatapayload - the payload for the Messagepublic GenericCommandMessage(T payload, Map<String,?> newMetaData)
command as payload.payload - the payload for the MessagenewMetaData - The meta data for this messagepublic GenericCommandMessage(String commandName, T payload, Map<String,?> newMetaData)
command as payload.commandName - The name of the commandpayload - the payload for the MessagenewMetaData - The meta data for this messagepublic GenericCommandMessage(String identifier, String commandName, T payload, Map<String,?> newMetaData)
command as payload and a custom chosen
identifier. Use this constructor to reconstruct instances of existing command messages, which have
already been assigned an identifier.identifier - the unique identifier of this messagecommandName - The name of the commandpayload - the payload for the MessagenewMetaData - The meta data for this message (null results in empty meta data)protected GenericCommandMessage(GenericCommandMessage<T> original, Map<String,?> metaData)
original is copied, except for the metaData.original - The original messagemetaData - The MetaData for the new messagepublic static CommandMessage 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 MetaData getMetaData()
MessagegetMetaData in interface Message<T>public T getPayload()
MessagegetPayload in interface Message<T>public Class getPayloadType()
MessagegetPayload().getClass(), but allows implementations to optimize by using
lazy loading or deserialization.getPayloadType in interface Message<T>public String getIdentifier()
MessagegetIdentifier in interface Message<T>public GenericCommandMessage<T> withMetaData(Map<String,?> newMetaData)
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>newMetaData - The new MetaData for the Messagepublic GenericCommandMessage<T> andMetaData(Map<String,?> additionalMetaData)
CommandMessagemetaData. The payload
remains unchanged.andMetaData in interface CommandMessage<T>andMetaData in interface Message<T>additionalMetaData - The MetaData to merge withCopyright © 2010-2014. All Rights Reserved.