public abstract class MessageDecorator<T> extends Object implements Message<T>, SerializationAware
Message that delegates to an existing message. Extend this decorator class to
extend the message with additional features.
Messages of this type are SerializationAware meaning they will not be serialized more than once by the same
serializer.
| Modifier | Constructor and Description |
|---|---|
protected |
MessageDecorator(Message<T> delegate)
Initializes a new decorator with given
delegate message. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
describeTo(StringBuilder stringBuilder)
Describe the message specific properties to the given
stringBuilder. |
protected String |
describeType()
Describe the type of message, used in
toString(). |
protected Message<T> |
getDelegate()
Returns the wrapped message delegate.
|
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.
|
<S> SerializedObject<S> |
serializeMetaData(Serializer serializer,
Class<S> expectedRepresentation)
Serialize the meta data of this message using given
serializer, using given
expectedRepresentation. |
<S> SerializedObject<S> |
serializePayload(Serializer serializer,
Class<S> expectedRepresentation)
Serialize the payload of this message using given
serializer, using given
expectedRepresentation. |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitandMetaData, withMetaDatapublic 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<T> getPayloadType()
MessagegetPayload().getClass(), but allows implementations to optimize by using
lazy loading or deserialization.getPayloadType in interface Message<T>public <S> SerializedObject<S> serializePayload(Serializer serializer, Class<S> expectedRepresentation)
SerializationAwareserializer, using given
expectedRepresentation. This method should return the same SerializedObject instance when
invoked multiple times using the same serializer.serializePayload in interface SerializationAwareS - The type of data to serialize toserializer - The serializer to serialize payload withexpectedRepresentation - The type of data to serialize topublic <S> SerializedObject<S> serializeMetaData(Serializer serializer, Class<S> expectedRepresentation)
SerializationAwareserializer, using given
expectedRepresentation. This method should return the same SerializedObject instance when
invoked multiple times using the same serializer.serializeMetaData in interface SerializationAwareS - The type of data to serialize toserializer - The serializer to serialize meta data withexpectedRepresentation - The type of data to serialize toprotected Message<T> getDelegate()
protected void describeTo(StringBuilder stringBuilder)
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.
stringBuilder - the builder to append data toprotected String describeType()
toString().
Defaults to the simple class name of the actual instance.
Copyright © 2010–2018. All rights reserved.