R
- The response type which will be matched against and converted topublic class MultipleInstancesResponseType<R> extends AbstractResponseType<List<R>>
ResponseType
implementation that will match with query handlers which return a multiple instances of the
expected response type. If matching succeeds, the ResponseType.convert(Object)
function will be called, which
will cast the query handler it's response to a List
with generic type R
.Modifier and Type | Field and Description |
---|---|
static int |
ITERABLE_MATCH
Indicates that the response matches with the
Type while returning an iterable result. |
expectedResponseType
MATCH, NO_MATCH
Constructor and Description |
---|
MultipleInstancesResponseType(Class<R> expectedCollectionGenericType)
Instantiate a
MultipleInstancesResponseType with the given expectedCollectionGenericType as the
type to be matched against and which the convert function will use as the generic for the List
return value. |
Modifier and Type | Method and Description |
---|---|
List<R> |
convert(Object response)
Converts the given
response of type Object into the type List with
generic type R from this ResponseType instance. |
boolean |
matches(Type responseType)
Match the query handler its response
Type with this implementation its responseType
R . |
Integer |
matchRank(Type responseType)
Match the query handler its response
Type with this implementation its responseType R . |
Class |
responseMessagePayloadType()
Returns a
Class representing the type of the payload to be contained in the response message. |
String |
toString() |
equals, getExpectedResponseType, hashCode, isArray, isArrayOfExpectedType, isAssignableFrom, isGenericArrayOfExpectedType, isGenericArrayType, isGenericAssignableFrom, isIterableOfExpectedType, isParameterizedType, isParameterizedTypeOfExpectedType, isPublisherOfExpectedType, isStreamOfExpectedType, isTypeVariable, isWildcardType, isWildcardTypeWithMatchingUpperBound, projectReactorOnClassPath, unwrapIfTypeFuture
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
convertExceptional, forSerialization
public static final int ITERABLE_MATCH
Type
while returning an iterable result.@ConstructorProperties(value="expectedResponseType") public MultipleInstancesResponseType(Class<R> expectedCollectionGenericType)
MultipleInstancesResponseType
with the given expectedCollectionGenericType
as the
type to be matched against and which the convert function will use as the generic for the List
return value.expectedCollectionGenericType
- the response type which is expected to be matched against and returnedpublic boolean matches(Type responseType)
Type
with this implementation its responseType
R
. Will return true in the following scenarios:
ExpectedType[]
GenericArrayType
of the expected type.
For example a <E extends ExpectedType> E[]
ParameterizedType
containing a single
TypeVariable
which is assignable to the response type, taking generic types into
account. For example a List<ExpectedType>
or <E extends ExpectedType> List<E>
.ParameterizedType
containing a single
WildcardType
which is assignable to the response type, taking generic types into
account. For example a <E extends ExpectedType> List<? extends E>
.Type
.If there is no match at all, it will return false to indicate a non-match.
responseType
- the response Type
of the query handler which is matched againstParameterizedType
s (like a Iterable
) for which the contained type is assignable to the expected type, ResponseType.MATCH
for matching single instances and ResponseType.NO_MATCH
for non-matchespublic Integer matchRank(Type responseType)
Type
with this implementation its responseType R
. Will
return a value greater than 0 in the following scenarios:
ITERABLE_MATCH
: If the response type is an array of the expected type. For example a ExpectedType[]
ITERABLE_MATCH
: If the response type is a GenericArrayType
of the expected type.
For example a <E extends ExpectedType> E[]
ITERABLE_MATCH
: If the response type is a ParameterizedType
containing a single
TypeVariable
which is assignable to the response type, taking generic types into
account. For example a List<ExpectedType>
or <E extends ExpectedType> List<E>
.ITERABLE_MATCH
: If the response type is a ParameterizedType
containing a single
WildcardType
which is assignable to the response type, taking generic types into
account. For example a <E extends ExpectedType> List<? extends E>
.ResponseType.MATCH
: If the responseType is a single instance type matching the given Type
.
If there is no match at all, it will return ResponseType.NO_MATCH
to indicate a non-match.
responseType
- the response Type
of the query handler which is matched againstITERABLE_MATCH
for arrays, generic arrays and ParameterizedType
s (like a Iterable
) for which the contained type is
assignable to the expected type, ResponseType.MATCH
for matching single instances and ResponseType.NO_MATCH
for non-matchespublic List<R> convert(Object response)
response
of type Object
into the type List
with
generic type R
from this ResponseType
instance. Will ensure that if the given response
is
of another collections format (e.g. an array, or a Stream
) that it will be converted to
a List. Should only be called if ResponseType.matches(Type)
returns true. Will throw an IllegalArgumentException
if the given response is not convertible to a List of the expected response
type.public Class responseMessagePayloadType()
ResponseType
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 messageCopyright © 2010–2023. All rights reserved.