T
- The type of payload contained in this Messagepublic interface Message<T> extends Serializable
Message
directly, consider implementing
{@code CommandMessage}
or EventMessage
instead.{@code CommandMessage}
,
EventMessage
Modifier and Type | Method and Description |
---|---|
Message<T> |
andMetaData(Map<String,?> metaData)
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<T> |
getPayloadType()
Returns the type of the payload.
|
default <R> SerializedObject<R> |
serializeMetaData(Serializer serializer,
Class<R> expectedRepresentation)
Serialize the meta data of this message to the
expectedRepresentation using given serializer . |
default <R> SerializedObject<R> |
serializePayload(Serializer serializer,
Class<R> expectedRepresentation)
Serialize the payload of this message to the
expectedRepresentation using given serializer . |
Message<T> |
withMetaData(Map<String,?> metaData)
Returns a copy of this Message with the given
metaData . |
String getIdentifier()
MetaData getMetaData()
T getPayload()
Class<T> getPayloadType()
getPayload().getClass()
, but allows implementations to optimize by using
lazy loading or deserialization.Message<T> withMetaData(Map<String,?> metaData)
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.metaData
- The new MetaData for the MessageMessage<T> andMetaData(Map<String,?> metaData)
metaData
. The payload
remains unchanged.metaData
- The MetaData to merge withdefault <R> SerializedObject<R> serializePayload(Serializer serializer, Class<R> expectedRepresentation)
expectedRepresentation
using given serializer
. This
method should return the same SerializedObject instance when invoked multiple times using the same
serializer.R
- The type of the serialized dataserializer
- The serializer to serialize payload withexpectedRepresentation
- The type of data to serialize todefault <R> SerializedObject<R> serializeMetaData(Serializer serializer, Class<R> expectedRepresentation)
expectedRepresentation
using given serializer
.
This method should return the same SerializedObject instance when invoked multiple times using the same
serializer.R
- The type of the serialized dataserializer
- The serializer to serialize meta data withexpectedRepresentation
- The type of data to serialize toCopyright © 2010–2018. All rights reserved.