R
- The type of return value contained in this responsepublic class GenericQueryResponseMessage<R> extends GenericResultMessage<R> implements QueryResponseMessage<R>
Constructor and Description |
---|
GenericQueryResponseMessage(Class<R> declaredResultType,
R result)
Initialize a response message with given
result and declaredResultType . |
GenericQueryResponseMessage(Class<R> declaredResultType,
R result,
Map<String,?> metaData)
Initialize the response message with a specific
declaredResultType , the given result as payload
and metaData . |
GenericQueryResponseMessage(Class<R> declaredResultType,
Throwable exception)
Initialize the response message with given
declaredResultType and exception . |
GenericQueryResponseMessage(Class<R> declaredResultType,
Throwable exception,
Map<String,?> metaData)
Initialize the response message with given
declaredResultType , exception and metaData . |
GenericQueryResponseMessage(Message<R> delegate)
Copy-constructor that takes the payload, meta data and message identifier of the given
delegate for this
message. |
GenericQueryResponseMessage(Message<R> delegate,
Throwable exception)
Copy-constructor that takes the payload, meta data and message identifier of the given
delegate for this
message and given exception as a cause for the failure. |
GenericQueryResponseMessage(R result)
Initialize the response message with given
result . |
GenericQueryResponseMessage(R result,
Map<String,?> metaData)
Initialize the response message with given
result and metaData . |
Modifier and Type | Method and Description |
---|---|
GenericQueryResponseMessage<R> |
andMetaData(Map<String,?> additionalMetaData)
Returns a copy of this Message with it MetaData merged with the given
metaData . |
static <R> QueryResponseMessage<R> |
asNullableResponseMessage(Class<R> declaredType,
Object result)
Creates a QueryResponseMessage for the given
result with a declaredType as the result type. |
static <R> QueryResponseMessage<R> |
asResponseMessage(Class<R> declaredType,
Throwable exception)
Creates a Query Response Message with given
declaredType and exception . |
static <R> QueryResponseMessage<R> |
asResponseMessage(Object result)
Creates a QueryResponseMessage for the given
result . |
GenericQueryResponseMessage<R> |
withMetaData(Map<String,?> metaData)
Returns a copy of this Message with the given
metaData . |
asResultMessage, asResultMessage, describeTo, describeType, 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 GenericQueryResponseMessage(R result)
result
.result
- The result reported by the Query Handler, may not be null
public GenericQueryResponseMessage(Class<R> declaredResultType, R result)
result
and declaredResultType
. This constructor allows
the actual result to be null
.declaredResultType
- The declared type of the resultresult
- The actual result. May be null
public GenericQueryResponseMessage(Class<R> declaredResultType, Throwable exception)
declaredResultType
and exception
.declaredResultType
- The declared type of the Query Response Message to be createdexception
- The Exception describing the cause of an errorpublic GenericQueryResponseMessage(R result, Map<String,?> metaData)
result
and metaData
.result
- The result reported by the Query Handler, may not be null
metaData
- The meta data to contain in the messagepublic GenericQueryResponseMessage(Class<R> declaredResultType, R result, Map<String,?> metaData)
declaredResultType
, the given result
as payload
and metaData
.declaredResultType
- A Class
denoting the declared result type of this query response
messageresult
- The result reported by the Query Handler, may be null
metaData
- The meta data to contain in the messagepublic GenericQueryResponseMessage(Class<R> declaredResultType, Throwable exception, Map<String,?> metaData)
declaredResultType
, exception
and metaData
.declaredResultType
- The declared type of the Query Response Message to be createdexception
- The Exception describing the cause of an errormetaData
- The meta data to contain in the messagepublic GenericQueryResponseMessage(Message<R> delegate)
delegate
for this
message.
Unlike the other constructors, this constructor will not attempt to retrieve any correlation data from the Unit of Work.
delegate
- The message to retrieve message details frompublic GenericQueryResponseMessage(Message<R> delegate, Throwable exception)
delegate
for this
message and given exception
as a cause for the failure.
Unlike the other constructors, this constructor will not attempt to retrieve any correlation data from the Unit of Work.
delegate
- The message to retrieve message details fromexception
- The Exception describing the cause of an errorpublic static <R> QueryResponseMessage<R> asResponseMessage(Object result)
result
. If result already implements QueryResponseMessage,
it is returned directly. Otherwise a new QueryResponseMessage is created with the result as payload.R
- The type of response expectedresult
- The result of a Query, to be wrapped in a QueryResponseMessageresult
, or the result itself, if already a
QueryResponseMessage.public static <R> QueryResponseMessage<R> asNullableResponseMessage(Class<R> declaredType, Object result)
result
with a declaredType
as the result type.
Providing both the result type and the result allows the creation of a nullable response message, as the
implementation does not have to check the type itself, which could result in a NullPointerException
. If result already implements QueryResponseMessage, it is returned directly.
Otherwise a new QueryResponseMessage is created with the declared type as the result type and the result as
payload.R
- The type of response expecteddeclaredType
- The declared type of the Query Response Message to be created.result
- The result of a Query, to be wrapped in a QueryResponseMessageresult
, or the result itself, if already a
QueryResponseMessage.public static <R> QueryResponseMessage<R> asResponseMessage(Class<R> declaredType, Throwable exception)
declaredType
and exception
.R
- The type of the payloaddeclaredType
- The declared type of the Query Response Message to be createdexception
- The Exception describing the cause of an errorpublic GenericQueryResponseMessage<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 Message<R>
withMetaData
in interface ResultMessage<R>
withMetaData
in interface QueryResponseMessage<R>
withMetaData
in class GenericResultMessage<R>
metaData
- The new MetaData for the Messagepublic GenericQueryResponseMessage<R> andMetaData(@Nonnull Map<String,?> additionalMetaData)
Message
metaData
. The payload remains
unchanged.andMetaData
in interface Message<R>
andMetaData
in interface ResultMessage<R>
andMetaData
in interface QueryResponseMessage<R>
andMetaData
in class GenericResultMessage<R>
additionalMetaData
- The MetaData to merge withCopyright © 2010–2023. All rights reserved.