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
.expectedResponseType
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 . |
Class |
responseMessagePayloadType()
Returns a
Class representing the type of the payload to be contained in the response message. |
getExpectedResponseType, isArray, isArrayOfExpectedType, isAssignableFrom, isGenericArrayOfExpectedType, isGenericArrayType, isGenericAssignableFrom, isIterableOfExpectedType, isParameterizedType, isParameterizedTypeOfExpectedType, isStreamOfExpectedType, isTypeVariable, isWildcardType, isWildcardTypeWithMatchingUpperBound, unwrapIfTypeFuture
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>
.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 typepublic 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–2018. All rights reserved.