R - the generic type of this ResponseType to be matched and converted.public interface ResponseType<R> extends Serializable
QueryBus/QueryGateway.
By wrapping the response type as a generic R, we can easily service the expected response as a single
instance, a list, a page etc., based on the selected implementation even while the query handler return type might be
slightly different.
It is in charge of matching the response type of a query handler with the given generic R.
If this match returns true, it signals the found query handler can handle the intended query.
As a follow up, the response retrieved from a query handler should move through the
convert(Object) function to guarantee the right response type is returned.to instantiate a {@link ResponseType} implementation| Modifier and Type | Method and Description |
|---|---|
default R |
convert(Object response)
|
Class<?> |
getExpectedResponseType()
Gets actual response type or generic placeholder.
|
boolean |
matches(Type responseType)
Match the query handler its response
Type with the ResponseType implementation
its expected response type R. |
Class<R> |
responseMessagePayloadType()
Returns a
Class representing the type of the payload to be contained in the response message. |
boolean matches(Type responseType)
Type with the ResponseType implementation
its expected response type R. Will return true if a response can be converted based on the given
responseType and false if it cannot.responseType - the response Type of the query handler which is matched againstresponseType and false if it cannotdefault R convert(Object response)
response of type Object into the type R of this
ResponseType instance. Should only be called if matches(Type) returns true.
It is unspecified what this function does if the matches(Type) returned false.response - the Object to convert into Rresponse of type RClass<R> responseMessagePayloadType()
Class representing the type of the payload to be contained in the response message.Class representing the type of the payload to be contained in the response messageClass<?> getExpectedResponseType()
Copyright © 2010–2018. All rights reserved.