public class GenericResultMessage<R> extends MessageDecorator<R> implements ResultMessage<R>
ResultMessage.| Constructor and Description |
|---|
GenericResultMessage(Message<R> delegate)
Creates a new ResultMessage with given
delegate message. |
GenericResultMessage(Message<R> delegate,
Throwable exception)
Creates a ResultMessage with given
delegate message and exception. |
GenericResultMessage(R result)
Creates a ResultMessage with the given
result as the payload. |
GenericResultMessage(R result,
Map<String,?> metaData)
Creates a ResultMessage with the given
result as the payload and metaData as the meta data. |
GenericResultMessage(Throwable exception)
Creates a ResultMessage with the given
exception. |
GenericResultMessage(Throwable exception,
Map<String,?> metaData)
Creates a ResultMessage with the given
exception and metaData. |
| Modifier and Type | Method and Description |
|---|---|
GenericResultMessage<R> |
andMetaData(Map<String,?> metaData)
Returns a copy of this Message with it MetaData merged with the given
metaData. |
static <T> ResultMessage<T> |
asResultMessage(Object result)
Returns the given
result as a ResultMessage instance. |
static <T> ResultMessage<T> |
asResultMessage(Throwable exception)
Creates a ResultMessage with the given
exception result. |
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(). |
R |
getPayload()
Returns the payload of this Event.
|
boolean |
isExceptional()
Indicates whether the ResultMessage represents unsuccessful execution.
|
Optional<Throwable> |
optionalExceptionResult()
Returns the Exception in case of exceptional result message or an empty
Optional in case of successful
execution. |
GenericResultMessage<R> |
withMetaData(Map<String,?> metaData)
Returns a copy of this Message with the given
metaData. |
getDelegate, getIdentifier, getMetaData, getPayloadType, serializeMetaData, serializePayload, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitexceptionResult, serializeExceptionResultgetIdentifier, getMetaData, getPayloadType, serializeMetaData, serializePayloadpublic GenericResultMessage(R result)
result as the payload.result - the payload for the Messagepublic GenericResultMessage(Throwable exception)
exception.exception - the Exception describing the cause of an errorpublic GenericResultMessage(R result, Map<String,?> metaData)
result as the payload and metaData as the meta data.result - the payload for the MessagemetaData - the meta data for the Messagepublic GenericResultMessage(Throwable exception, Map<String,?> metaData)
exception and metaData.exception - the Exception describing the cause of an errormetaData - the meta data for the Messagepublic GenericResultMessage(Message<R> delegate)
delegate message.delegate - the message delegatepublic static <T> ResultMessage<T> asResultMessage(Object result)
result as a ResultMessage instance. If result already implements ResultMessage, it is returned as-is. If result implements Message, payload and meta data will be
used to construct new GenericResultMessage. Otherwise, the given result is wrapped into a GenericResultMessage as its payload.T - The type of the payload contained in returned Messageresult - the command result to be wrapped as ResultMessageresult as payload, or result if already
implements ResultMessagepublic static <T> ResultMessage<T> asResultMessage(Throwable exception)
exception result.T - the type of payloadexception - the Exception describing the cause of an errorpublic boolean isExceptional()
ResultMessageisExceptional in interface ResultMessage<R>true if execution was unsuccessful, false otherwisepublic Optional<Throwable> optionalExceptionResult()
ResultMessageOptional in case of successful
execution.optionalExceptionResult in interface ResultMessage<R>Optional containing exception result or an empty Optional in case of a successful executionpublic GenericResultMessage<R> withMetaData(Map<String,?> metaData)
MessagemetaData. 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 Message<R>withMetaData in interface ResultMessage<R>metaData - The new MetaData for the Messagepublic GenericResultMessage<R> andMetaData(Map<String,?> metaData)
MessagemetaData. The payload
remains unchanged.andMetaData in interface Message<R>andMetaData in interface ResultMessage<R>metaData - The MetaData to merge withprotected void describeTo(StringBuilder stringBuilder)
MessageDecoratorstringBuilder. 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<R>stringBuilder - the builder to append data toprotected String describeType()
MessageDecoratorMessageDecorator.toString().
Defaults to the simple class name of the actual instance.
describeType in class MessageDecorator<R>public R getPayload()
MessagegetPayload in interface Message<R>getPayload in class MessageDecorator<R>Copyright © 2010–2018. All rights reserved.