T
- The type of payload contained in this Messagepublic class GenericEventMessage<T> extends GenericMessage<T> implements EventMessage<T>
Constructor and Description |
---|
GenericEventMessage(String identifier,
org.joda.time.DateTime timestamp,
T payload,
Map<String,?> metaData)
Constructor to reconstruct an EventMessage using existing data.
|
GenericEventMessage(T payload)
Creates a GenericEventMessage with given
payload , and an empty MetaData. |
GenericEventMessage(T payload,
Map<String,?> metaData)
Creates a GenericEventMessage with given
payload and given metaData . |
Modifier and Type | Method and Description |
---|---|
GenericEventMessage<T> |
andMetaData(Map<String,?> additionalMetaData)
Returns a copy of this Message with it MetaData merged with the given
metaData . |
static <T> EventMessage<T> |
asEventMessage(Object event)
Returns the given event as an EventMessage.
|
org.joda.time.DateTime |
getTimestamp()
Returns the timestamp of this event.
|
String |
toString() |
GenericEventMessage<T> |
withMetaData(Map<String,?> newMetaData)
Returns a copy of this Message with the given
metaData . |
getIdentifier, getMetaData, getPayload, getPayloadType
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getIdentifier
getMetaData, getPayload, getPayloadType
public GenericEventMessage(T payload)
payload
, and an empty MetaData.payload
- The payload for the messageasEventMessage(Object)
public GenericEventMessage(T payload, Map<String,?> metaData)
payload
and given metaData
.payload
- The payload of the EventMessagemetaData
- The MetaData for the EventMessageasEventMessage(Object)
public GenericEventMessage(String identifier, org.joda.time.DateTime timestamp, T payload, Map<String,?> metaData)
identifier
- The identifier of the Messagetimestamp
- The timestamp of the Message creationpayload
- The payload of the messagemetaData
- The meta data of the messagepublic static <T> EventMessage<T> asEventMessage(Object event)
event
already implements EventMessage, it is
returned as-is. If it is a Message, a new EventMessage will be created using the payload and meta data of the
given message. Otherwise, the given event
is wrapped into a GenericEventMessage as its payload.T
- The generic type of the expected payload of the resulting objectevent
- the event to wrap as EventMessageevent
as payload, or event
if it already
implements EventMessage.public org.joda.time.DateTime getTimestamp()
EventMessage
getTimestamp
in interface EventMessage<T>
public GenericEventMessage<T> withMetaData(Map<String,?> newMetaData)
Message
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 EventMessage<T>
withMetaData
in interface Message<T>
withMetaData
in class GenericMessage<T>
newMetaData
- The new MetaData for the Messagepublic GenericEventMessage<T> andMetaData(Map<String,?> additionalMetaData)
Message
metaData
. The payload
remains unchanged.andMetaData
in interface EventMessage<T>
andMetaData
in interface Message<T>
andMetaData
in class GenericMessage<T>
additionalMetaData
- The MetaData to merge withCopyright © 2010-2014. All Rights Reserved.