Class GenericCommandResultMessage<R>
java.lang.Object
org.axonframework.messaging.MessageDecorator<R>
org.axonframework.messaging.GenericResultMessage<R>
org.axonframework.commandhandling.GenericCommandResultMessage<R>
- Type Parameters:
R- The type of the payload contained in this Message
- All Implemented Interfaces:
Serializable,CommandResultMessage<R>,Message<R>,ResultMessage<R>
public class GenericCommandResultMessage<R>
extends GenericResultMessage<R>
implements CommandResultMessage<R>
Generic implementation of
CommandResultMessage.- Since:
- 4.0
- Author:
- Milan Savic
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionGenericCommandResultMessage(Throwable exception) Creates a Command Result Message with the givenexception.GenericCommandResultMessage(Throwable exception, Map<String, ?> metaData) Creates a Command Result Message with the givenexceptionandmetaData.GenericCommandResultMessage(Message<R> delegate) Creates a new Command Result Message with givendelegatemessage.GenericCommandResultMessage(Message<R> delegate, Throwable exception) Creates a Command Result Message with givendelegatemessage andexception.GenericCommandResultMessage(R commandResult) Creates a Command Result Message with the givencommandResultas the payload.GenericCommandResultMessage(R commandResult, Map<String, ?> metaData) Creates a Command Result Message with the givencommandResultas the payload andmetaDataas the meta data. -
Method Summary
Modifier and TypeMethodDescriptionandMetaData(Map<String, ?> metaData) Returns a copy of this Message with it MetaData merged with the givenmetaData.static <T> CommandResultMessage<T> asCommandResultMessage(Object commandResult) Returns the givencommandResultas aCommandResultMessageinstance.static <T> CommandResultMessage<T> asCommandResultMessage(Throwable exception) Creates a Command Result Message with the givenexceptionresult.protected StringDescribe the type of message, used inMessageDecorator.toString().withMetaData(Map<String, ?> metaData) Returns a copy of this Message with the givenmetaData.Methods inherited from class org.axonframework.messaging.GenericResultMessage
asResultMessage, asResultMessage, describeTo, getPayload, isExceptional, optionalExceptionResult, serializePayloadMethods inherited from class org.axonframework.messaging.MessageDecorator
getDelegate, getIdentifier, getMetaData, getPayloadType, serializeMetaData, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.axonframework.messaging.Message
getIdentifier, getMetaData, getPayload, getPayloadType, serializeMetaDataMethods inherited from interface org.axonframework.messaging.ResultMessage
exceptionDetails, exceptionResult, isExceptional, optionalExceptionResult, serializeExceptionResult, serializePayload
-
Constructor Details
-
GenericCommandResultMessage
Creates a Command Result Message with the givencommandResultas the payload.- Parameters:
commandResult- the payload for the Message
-
GenericCommandResultMessage
Creates a Command Result Message with the givenexception.- Parameters:
exception- the Exception describing the cause of an error
-
GenericCommandResultMessage
Creates a Command Result Message with the givencommandResultas the payload andmetaDataas the meta data.- Parameters:
commandResult- the payload for the MessagemetaData- the meta data for the Message
-
GenericCommandResultMessage
Creates a Command Result Message with the givenexceptionandmetaData.- Parameters:
exception- the Exception describing the cause of an errormetaData- the meta data for the Message
-
GenericCommandResultMessage
Creates a new Command Result Message with givendelegatemessage.- Parameters:
delegate- the message delegate
-
GenericCommandResultMessage
Creates a Command Result Message with givendelegatemessage andexception.- Parameters:
delegate- the Message delegateexception- the Exception describing the cause of an error
-
-
Method Details
-
asCommandResultMessage
Returns the givencommandResultas aCommandResultMessageinstance. IfcommandResultalready implementsCommandResultMessage, it is returned as-is. IfcommandResultimplementsMessage, payload and meta data will be used to construct newGenericCommandResultMessage. Otherwise, the givencommandResultis wrapped into aGenericCommandResultMessageas its payload.- Type Parameters:
T- The type of the payload contained in returned Message- Parameters:
commandResult- the command result to be wrapped asCommandResultMessage- Returns:
- a Message containing given
commandResultas payload, orcommandResultif already implementsCommandResultMessage
-
asCommandResultMessage
Creates a Command Result Message with the givenexceptionresult.- Type Parameters:
T- the type of payload- Parameters:
exception- the Exception describing the cause of an error- Returns:
- a message containing exception result
-
withMetaData
Description copied from interface:MessageReturns a copy of this Message with the givenmetaData. The payload remains unchanged. While the implementation returned may be different than the implementation ofthis, implementations must take special care in returning the same type of Message (e.g. EventMessage, DomainEventMessage) to prevent errors further downstream.- Specified by:
withMetaDatain interfaceCommandResultMessage<R>- Specified by:
withMetaDatain interfaceMessage<R>- Specified by:
withMetaDatain interfaceResultMessage<R>- Overrides:
withMetaDatain classGenericResultMessage<R>- Parameters:
metaData- The new MetaData for the Message- Returns:
- a copy of this message with the given MetaData
-
andMetaData
Description copied from interface:MessageReturns a copy of this Message with it MetaData merged with the givenmetaData. The payload remains unchanged.- Specified by:
andMetaDatain interfaceCommandResultMessage<R>- Specified by:
andMetaDatain interfaceMessage<R>- Specified by:
andMetaDatain interfaceResultMessage<R>- Overrides:
andMetaDatain classGenericResultMessage<R>- Parameters:
metaData- The MetaData to merge with- Returns:
- a copy of this message with the given MetaData
-
describeType
Description copied from class:MessageDecoratorDescribe the type of message, used inMessageDecorator.toString().Defaults to the simple class name of the actual instance.
- Overrides:
describeTypein classGenericResultMessage<R>- Returns:
- the type of message
-