Class MultipleInstancesResponseType<R>
java.lang.Object
org.axonframework.messaging.responsetypes.AbstractResponseType<List<R>>
org.axonframework.messaging.responsetypes.MultipleInstancesResponseType<R>
- Type Parameters:
R- The response type which will be matched against and converted to
- All Implemented Interfaces:
Serializable,ResponseType<List<R>>
A
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.- Since:
- 3.2
- Author:
- Steven van Beelen
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intIndicates that the response matches with theTypewhile returning an iterable result.Fields inherited from class org.axonframework.messaging.responsetypes.AbstractResponseType
expectedResponseTypeFields inherited from interface org.axonframework.messaging.responsetypes.ResponseType
MATCH, NO_MATCH -
Constructor Summary
ConstructorsConstructorDescriptionMultipleInstancesResponseType(Class<R> expectedCollectionGenericType) Instantiate aMultipleInstancesResponseTypewith the givenexpectedCollectionGenericTypeas the type to be matched against and which the convert function will use as the generic for theListreturn value. -
Method Summary
Modifier and TypeMethodDescriptionConverts the givenresponseof typeObjectinto the typeListwith generic typeRfrom thisResponseTypeinstance.booleanMatch the query handler its responseTypewith this implementation its responseTypeR.Match the query handler its responseTypewith this implementation its responseTypeR.Returns aClassrepresenting the type of the payload to be contained in the response message.toString()Methods inherited from class org.axonframework.messaging.responsetypes.AbstractResponseType
equals, getExpectedResponseType, hashCode, isArray, isArrayOfExpectedType, isAssignableFrom, isGenericArrayOfExpectedType, isGenericArrayType, isGenericAssignableFrom, isIterableOfExpectedType, isParameterizedType, isParameterizedTypeOfExpectedType, isPublisherOfExpectedType, isStreamOfExpectedType, isTypeVariable, isWildcardType, isWildcardTypeWithMatchingUpperBound, projectReactorOnClassPath, unwrapIfTypeFutureMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.axonframework.messaging.responsetypes.ResponseType
convertExceptional, forSerialization
-
Field Details
-
ITERABLE_MATCH
public static final int ITERABLE_MATCHIndicates that the response matches with theTypewhile returning an iterable result.
-
-
Constructor Details
-
MultipleInstancesResponseType
@ConstructorProperties("expectedResponseType") public MultipleInstancesResponseType(Class<R> expectedCollectionGenericType) Instantiate aMultipleInstancesResponseTypewith the givenexpectedCollectionGenericTypeas the type to be matched against and which the convert function will use as the generic for theListreturn value.- Parameters:
expectedCollectionGenericType- the response type which is expected to be matched against and returned
-
-
Method Details
-
matches
Match the query handler its responseTypewith this implementation its responseTypeR. Will return true in the following scenarios:- If the response type is an array of the expected type. For example a
ExpectedType[] - If the response type is a
GenericArrayTypeof the expected type. For example a<E extends ExpectedType> E[] - If the response type is a
ParameterizedTypecontaining a singleTypeVariablewhich is assignable to the response type, taking generic types into account. For example aList<ExpectedType>or<E extends ExpectedType> List<E>. - If the response type is a
ParameterizedTypecontaining a singleWildcardTypewhich is assignable to the response type, taking generic types into account. For example a<E extends ExpectedType> List<? extends E>. - If the responseType is a single instance type matching the given
Type.
If there is no match at all, it will return false to indicate a non-match.
- Parameters:
responseType- the responseTypeof the query handler which is matched against- Returns:
- true for arrays, generic arrays and
ParameterizedTypes (like aIterable) for which the contained type is assignable to the expected type,ResponseType.MATCHfor matching single instances andResponseType.NO_MATCHfor non-matches
- If the response type is an array of the expected type. For example a
-
matchRank
Match the query handler its responseTypewith this implementation its responseTypeR. 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 aExpectedType[]ITERABLE_MATCH: If the response type is aGenericArrayTypeof the expected type. For example a<E extends ExpectedType> E[]ITERABLE_MATCH: If the response type is aParameterizedTypecontaining a singleTypeVariablewhich is assignable to the response type, taking generic types into account. For example aList<ExpectedType>or<E extends ExpectedType> List<E>.ITERABLE_MATCH: If the response type is aParameterizedTypecontaining a singleWildcardTypewhich 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 givenType.
If there is no match at all, it will return
ResponseType.NO_MATCHto indicate a non-match.- Parameters:
responseType- the responseTypeof the query handler which is matched against- Returns:
ITERABLE_MATCHfor arrays, generic arrays andParameterizedTypes (like aIterable) for which the contained type is assignable to the expected type,ResponseType.MATCHfor matching single instances andResponseType.NO_MATCHfor non-matches
-
convert
Converts the givenresponseof typeObjectinto the typeListwith generic typeRfrom thisResponseTypeinstance. Will ensure that if the givenresponseis of another collections format (e.g. an array, or aStream) that it will be converted to a List. Should only be called ifResponseType.matches(Type)returns true. Will throw anIllegalArgumentExceptionif the given response is not convertible to a List of the expected response type. -
responseMessagePayloadType
Description copied from interface:ResponseTypeReturns aClassrepresenting the type of the payload to be contained in the response message.- Returns:
- a
Classrepresenting the type of the payload to be contained in the response message
-
toString
-