Class GenericQueryResponseMessage
- All Implemented Interfaces:
Message,ResultMessage,QueryResponseMessage
QueryResponseMessage interface.- Since:
- 3.2.0
- Author:
- Allard Buijze, Steven van Beelen
-
Field Summary
Fields inherited from interface org.axonframework.messaging.core.Message
RESOURCE_KEY -
Constructor Summary
ConstructorsConstructorDescriptionGenericQueryResponseMessage(Message delegate) Constructs aGenericQueryResponseMessagefor the givendelegate, intended to reconstruct anotherQueryResponseMessage.GenericQueryResponseMessage(MessageType type, Object result) Constructs aGenericQueryResponseMessagefor the giventypeandpayload.GenericQueryResponseMessage(MessageType type, Object result, Map<String, String> metadata) Constructs aGenericQueryResponseMessagefor the giventype,result, andmetadata.GenericQueryResponseMessage(MessageType type, R result, Class<R> declaredResultType) Constructs aGenericQueryResponseMessagefor the giventypeandpayload.GenericQueryResponseMessage(MessageType type, R result, Class<R> declaredResultType, Map<String, String> metadata) Constructs aGenericQueryResponseMessagefor the giventype,result, andmetadata. -
Method Summary
Modifier and TypeMethodDescriptionandMetadata(Map<String, String> additionalMetadata) withConvertedPayload(Type type, Converter converter) Returns a newMessageimplementation with itsMessage.payload()converted to the giventypeby the givenconverter.withMetadata(Map<String, String> metadata) Returns a copy of thisMessage(implementation) with the givenmetadata.Methods inherited from class org.axonframework.messaging.core.GenericResultMessage
asResultMessage, describeTypeMethods inherited from class org.axonframework.messaging.core.MessageDecorator
delegate, describeTo, identifier, metadata, payload, payloadAs, payloadType, toString, typeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.axonframework.messaging.core.Message
identifier, metadata, payload, payloadAs, payloadAs, payloadAs, payloadAs, payloadAs, payloadType, typeMethods inherited from interface org.axonframework.messaging.queryhandling.QueryResponseMessage
withConvertedPayload, withConvertedPayload
-
Constructor Details
-
GenericQueryResponseMessage
Constructs aGenericQueryResponseMessagefor the giventypeandpayload.The
Metadatadefaults to an empty instance.- Parameters:
type- Thetypefor thisQueryResponseMessage.result- The result for thisQueryResponseMessage.
-
GenericQueryResponseMessage
public GenericQueryResponseMessage(@Nonnull MessageType type, @Nullable R result, @Nonnull Class<R> declaredResultType) Constructs aGenericQueryResponseMessagefor the giventypeandpayload.This constructor allows the actual result to be
null. TheMetadatadefaults to an empty instance.- Type Parameters:
R- The generic type of the expected payload of the resulting object.- Parameters:
type- Thetypefor thisQueryResponseMessage.result- The result of typeRfor thisQueryResponseMessage. May benull.declaredResultType- The declared result type of thisQueryResponseMessage.
-
GenericQueryResponseMessage
public GenericQueryResponseMessage(@Nonnull MessageType type, @Nullable Object result, @Nonnull Map<String, String> metadata) Constructs aGenericQueryResponseMessagefor the giventype,result, andmetadata.This constructor allows the actual result to be
null.- Parameters:
type- Thetypefor thisQueryResponseMessage.result- The result for thisQueryResponseMessage. May benull.metadata- The metadata for thisQueryResponseMessage.
-
GenericQueryResponseMessage
public GenericQueryResponseMessage(@Nonnull MessageType type, @Nullable R result, @Nonnull Class<R> declaredResultType, @Nonnull Map<String, String> metadata) Constructs aGenericQueryResponseMessagefor the giventype,result, andmetadata.This constructor allows the actual result to be
null.- Type Parameters:
R- The generic type of the expected payload of the resulting object.- Parameters:
type- Thetypefor thisQueryResponseMessage.result- The result of typeRfor thisQueryResponseMessage. May benull.declaredResultType- The declared result type of thisQueryResponseMessage.metadata- The metadata for thisQueryResponseMessage.
-
GenericQueryResponseMessage
Constructs aGenericQueryResponseMessagefor the givendelegate, intended to reconstruct anotherQueryResponseMessage.Unlike the other constructors, this constructor will not attempt to retrieve any correlation data from the Unit of Work.
- Parameters:
delegate- TheMessagecontainingpayload,type,identifierandmetadatafor theQueryResponseMessageto reconstruct.
-
-
Method Details
-
withMetadata
Description copied from interface:MessageReturns a copy of thisMessage(implementation) with the givenmetadata.All other fields, like for example the
Message.payload(), remain unchanged.While the implementation returned may be different from the implementation of
this, implementations must take special care in returning the same type ofMessageto prevent errors further downstream.- Specified by:
withMetadatain interfaceMessage- Specified by:
withMetadatain interfaceQueryResponseMessage- Specified by:
withMetadatain interfaceResultMessage- Overrides:
withMetadatain classGenericResultMessage- Parameters:
metadata- The new metadata for theMessage.- Returns:
- A copy of
this Message (implementation)with the givenmetadata.
-
andMetadata
Description copied from interface:MessageReturns a copy of thisMessage(implementation) with itsmetadatamerged with the givenmetadata.All other fields, like for example the
Message.payload(), remain unchanged.- Specified by:
andMetadatain interfaceMessage- Specified by:
andMetadatain interfaceQueryResponseMessage- Specified by:
andMetadatain interfaceResultMessage- Overrides:
andMetadatain classGenericResultMessage- Parameters:
additionalMetadata- The metadata to merge with.- Returns:
- A copy of
this Message (implementation)with the givenmetadata.
-
withConvertedPayload
@Nonnull public QueryResponseMessage withConvertedPayload(@Nonnull Type type, @Nonnull Converter converter) Description copied from interface:MessageReturns a newMessageimplementation with itsMessage.payload()converted to the giventypeby the givenconverter. This newMessageis effectively a copy ofthis Messagewith a renewed payload andMessage.payloadType().Will return the
thisinstance if thepayload typeisassignable fromthe converted result.- Specified by:
withConvertedPayloadin interfaceMessage- Specified by:
withConvertedPayloadin interfaceQueryResponseMessage- Specified by:
withConvertedPayloadin interfaceResultMessage- Overrides:
withConvertedPayloadin classGenericResultMessage- Parameters:
type- The type to convert theMessage.payload()to.converter- The converter to convert theMessage.payload()with.- Returns:
- A new
Messageimplementation with itsMessage.payload()converted to the giventypeby the givenconverter.
-