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.
|
protected void |
describeTo(StringBuilder stringBuilder)
Describe the message specific properties to the given
stringBuilder . |
protected String |
describeType()
Describe the type of message, used in
MessageDecorator.toString() . |
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, serializePayload, toString
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, 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()
EventMessage
getTimestamp
in interface EventMessage<T>
public GenericEventMessage<T> withMetaData(Map<String,?> metaData)
EventMessage
metaData
. 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)
EventMessage
metaData
. The payload,
Timestamp
and Identifier
remain unchanged.andMetaData
in interface EventMessage<T>
andMetaData
in interface Message<T>
metaData
- The MetaData to merge withprotected void describeTo(StringBuilder stringBuilder)
MessageDecorator
stringBuilder
. Subclasses should override this
method, calling the super method and appending their own properties to the end (or beginning).
As convention, String values should be enclosed in single quotes, Objects in curly brackets and numeric values may be appended without enclosing. All properties should be preceded by a comma when appending, or finish with a comma when prefixing values.
describeTo
in class MessageDecorator<T>
stringBuilder
- the builder to append data toprotected String describeType()
MessageDecorator
MessageDecorator.toString()
.
Defaults to the simple class name of the actual instance.
describeType
in class MessageDecorator<T>
Copyright © 2010–2018. All rights reserved.