T - The type of payload contained in this messagepublic class GenericMessage<T> extends Object implements Message<T>
| Constructor and Description |
|---|
GenericMessage(String identifier,
T payload,
Map<String,?> metaData)
Constructor to reconstruct a Message using existing data.
|
GenericMessage(T payload)
Constructs a Message for the given
payload using empty meta data. |
GenericMessage(T payload,
Map<String,?> metaData)
Constructs a Message for the given
payload and meta data. |
| Modifier and Type | Method and Description |
|---|---|
GenericMessage<T> |
andMetaData(Map<String,?> additionalMetaData)
Returns a copy of this Message with it MetaData merged with the given
metaData. |
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.
|
GenericMessage<T> |
withMetaData(Map<String,?> newMetaData)
Returns a copy of this Message with the given
metaData. |
public GenericMessage(T payload)
payload using empty meta data.payload - The payload for the messagepublic GenericMessage(T payload, Map<String,?> metaData)
payload and meta data.payload - The payload for the messagemetaData - The meta data for the messagepublic String getIdentifier()
MessagegetIdentifier in interface Message<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 GenericMessage<T> withMetaData(Map<String,?> newMetaData)
MessagemetaData. 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 Message<T>newMetaData - The new MetaData for the Messagepublic GenericMessage<T> andMetaData(Map<String,?> additionalMetaData)
MessagemetaData. The payload
remains unchanged.andMetaData in interface Message<T>additionalMetaData - The MetaData to merge withCopyright © 2010-2014. All Rights Reserved.