T - The type of payload contained in this Messagepublic class GenericEventMessage<T> extends MessageDecorator<T> implements EventMessage<T>
| Modifier and Type | Field and Description |
|---|---|
static Clock |
clock
Clock instance used to set the time on new events. |
| Modifier | Constructor and Description |
|---|---|
protected |
GenericEventMessage(Message<T> delegate,
Instant timestamp)
Initializes a
GenericEventMessage with given message as delegate and given timestamp. |
|
GenericEventMessage(Message<T> delegate,
Supplier<Instant> timestampSupplier)
Constructor to reconstruct an EventMessage using existing data.
|
|
GenericEventMessage(String identifier,
T payload,
Map<String,?> metaData,
Instant timestamp)
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,?> metaData)
Returns a copy of this EventMessage with it MetaData merged with the given
metaData. |
static <T> EventMessage<T> |
asEventMessage(Object event)
Returns the given event as an EventMessage.
|
Instant |
getTimestamp()
Returns the timestamp of this event.
|
GenericEventMessage<T> |
withMetaData(Map<String,?> metaData)
Returns a copy of this EventMessage with the given
metaData. |
getDelegate, getIdentifier, getMetaData, getPayload, getPayloadType, serializeMetaData, serializePayloadclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetIdentifiergetMetaData, getPayload, getPayloadTypepublic 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, T payload, Map<String,?> metaData, Instant timestamp)
identifier - The identifier of the Messagetimestamp - The timestamp of the Message creationpayload - The payload of the messagemetaData - The meta data of the messagepublic GenericEventMessage(Message<T> delegate, Supplier<Instant> timestampSupplier)
delegate - The message containing payload, identifier and metadatatimestampSupplier - Supplier for the timestamp of the Message creationprotected GenericEventMessage(Message<T> delegate, Instant timestamp)
GenericEventMessage with given message as delegate and given timestamp. The
given message will be used supply the payload, metadata and identifier of the resulting event message.delegate - the message that will be used used as delegatetimestamp - the timestamp of the resulting event 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 Instant getTimestamp()
EventMessagegetTimestamp in interface EventMessage<T>public GenericEventMessage<T> withMetaData(Map<String,?> metaData)
EventMessagemetaData. The payload, Timestamp and Identifier remain unchanged.withMetaData in interface EventMessage<T>withMetaData in interface Message<T>metaData - The new MetaData for the Messagepublic GenericEventMessage<T> andMetaData(Map<String,?> metaData)
EventMessagemetaData. The payload,
Timestamp and Identifier remain unchanged.andMetaData in interface EventMessage<T>andMetaData in interface Message<T>metaData - The MetaData to merge withCopyright © 2010–2017. All rights reserved.