R
- The type of the payload contained in this Messagepublic class GenericCommandResultMessage<R> extends GenericResultMessage<R> implements CommandResultMessage<R>
CommandResultMessage
.Constructor and Description |
---|
GenericCommandResultMessage(Message<R> delegate)
Creates a new Command Result Message with given
delegate message. |
GenericCommandResultMessage(Message<R> delegate,
Throwable exception)
Creates a Command Result Message with given
delegate message and exception . |
GenericCommandResultMessage(R commandResult)
Creates a Command Result Message with the given
commandResult as the payload. |
GenericCommandResultMessage(R commandResult,
Map<String,?> metaData)
Creates a Command Result Message with the given
commandResult as the payload and metaData as the
meta data. |
GenericCommandResultMessage(Throwable exception)
Creates a Command Result Message with the given
exception . |
GenericCommandResultMessage(Throwable exception,
Map<String,?> metaData)
Creates a Command Result Message with the given
exception and metaData . |
Modifier and Type | Method and Description |
---|---|
GenericCommandResultMessage<R> |
andMetaData(Map<String,?> metaData)
Returns a copy of this Message with it MetaData merged with the given
metaData . |
static <T> CommandResultMessage<T> |
asCommandResultMessage(Object commandResult)
Returns the given
commandResult as a CommandResultMessage instance. |
static <T> CommandResultMessage<T> |
asCommandResultMessage(Throwable exception)
Creates a Command Result Message with the given
exception result. |
protected String |
describeType()
Describe the type of message, used in
MessageDecorator.toString() . |
GenericCommandResultMessage<R> |
withMetaData(Map<String,?> metaData)
Returns a copy of this Message with the given
metaData . |
asResultMessage, asResultMessage, describeTo, getPayload, isExceptional, optionalExceptionResult, serializePayload
getDelegate, getIdentifier, getMetaData, getPayloadType, serializeMetaData, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
exceptionDetails, exceptionResult, isExceptional, optionalExceptionResult, serializeExceptionResult, serializePayload
getIdentifier, getMetaData, getPayload, getPayloadType, serializeMetaData
public GenericCommandResultMessage(@Nullable R commandResult)
commandResult
as the payload.commandResult
- the payload for the Messagepublic GenericCommandResultMessage(@Nonnull Throwable exception)
exception
.exception
- the Exception describing the cause of an errorpublic GenericCommandResultMessage(@Nonnull R commandResult, @Nonnull Map<String,?> metaData)
commandResult
as the payload and metaData
as the
meta data.commandResult
- the payload for the MessagemetaData
- the meta data for the Messagepublic GenericCommandResultMessage(@Nonnull Throwable exception, @Nonnull Map<String,?> metaData)
exception
and metaData
.exception
- the Exception describing the cause of an errormetaData
- the meta data for the Messagepublic GenericCommandResultMessage(@Nonnull Message<R> delegate)
delegate
message.delegate
- the message delegatepublic GenericCommandResultMessage(@Nonnull Message<R> delegate, @Nullable Throwable exception)
delegate
message and exception
.delegate
- the Message delegateexception
- the Exception describing the cause of an errorpublic static <T> CommandResultMessage<T> asCommandResultMessage(@Nonnull Object commandResult)
commandResult
as a CommandResultMessage
instance. If commandResult
already implements CommandResultMessage
, it is returned as-is. If commandResult
implements Message
, payload and meta data will be used to construct new GenericCommandResultMessage
. Otherwise, the
given commandResult
is wrapped into a GenericCommandResultMessage
as its payload.T
- The type of the payload contained in returned MessagecommandResult
- the command result to be wrapped as CommandResultMessage
commandResult
as payload, or commandResult
if already
implements CommandResultMessage
public static <T> CommandResultMessage<T> asCommandResultMessage(@Nonnull Throwable exception)
exception
result.T
- the type of payloadexception
- the Exception describing the cause of an errorpublic GenericCommandResultMessage<R> withMetaData(@Nonnull Map<String,?> metaData)
Message
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.withMetaData
in interface CommandResultMessage<R>
withMetaData
in interface Message<R>
withMetaData
in interface ResultMessage<R>
withMetaData
in class GenericResultMessage<R>
metaData
- The new MetaData for the Messagepublic GenericCommandResultMessage<R> andMetaData(@Nonnull Map<String,?> metaData)
Message
metaData
. The payload remains
unchanged.andMetaData
in interface CommandResultMessage<R>
andMetaData
in interface Message<R>
andMetaData
in interface ResultMessage<R>
andMetaData
in class GenericResultMessage<R>
metaData
- The MetaData to merge withprotected String describeType()
MessageDecorator
MessageDecorator.toString()
.
Defaults to the simple class name of the actual instance.
describeType
in class GenericResultMessage<R>
Copyright © 2010–2024. All rights reserved.