R - The response type which will be matched against and converted topublic class PublisherResponseType<R> extends AbstractResponseType<org.reactivestreams.Publisher<R>>
ResponseType implementation that will match with query
handlers that return a Publisher stream 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
R.| Modifier and Type | Field and Description |
|---|---|
static int |
PUBLISHER_MATCH
Indicates that the response matches with the
Type while returning a publisher result. |
expectedResponseTypeMATCH, NO_MATCH| Constructor and Description |
|---|
PublisherResponseType(Class<?> expectedResponseType)
Instantiate a
PublisherResponseType with the given
expectedResponseType as the type to be matched against and to which the query response should be
converted to. |
| Modifier and Type | Method and Description |
|---|---|
org.reactivestreams.Publisher<R> |
convert(Object queryResponse)
|
Optional<org.reactivestreams.Publisher<R>> |
convertExceptional(Throwable e)
|
ResponseType<?> |
forSerialization()
Returns the
ResponseType instance that should be used when serializing responses. |
boolean |
matches(Type responseType)
Match the query handler its response
Type with this implementation its responseType
R. |
Integer |
matchRank(Type responseType)
Defines the match and its priority.
|
Class |
responseMessagePayloadType()
Returns a
Class representing the type of the payload to be contained in the response message. |
equals, getExpectedResponseType, hashCode, isArray, isArrayOfExpectedType, isAssignableFrom, isGenericArrayOfExpectedType, isGenericArrayType, isGenericAssignableFrom, isIterableOfExpectedType, isParameterizedType, isParameterizedTypeOfExpectedType, isPublisherOfExpectedType, isStreamOfExpectedType, isTypeVariable, isWildcardType, isWildcardTypeWithMatchingUpperBound, projectReactorOnClassPath, unwrapIfTypeFuturepublic static final int PUBLISHER_MATCH
Type while returning a publisher result.public PublisherResponseType(Class<?> expectedResponseType)
PublisherResponseType with the given
expectedResponseType as the type to be matched against and to which the query response should be
converted to.expectedResponseType - 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 if the expected type is assignable to the response type, taking generic types into account.responseType - the response Type of the query handler which is matched againstpublic Integer matchRank(Type responseType)
ResponseTypeMultipleInstancesResponseTypes when there are matches on a both
multiple and single instance types. Lists should be given priority for handling.
ResponseType#ITERABLE_MATCH ResponseType#SINGLE_MATCH ResponseType.NO_MATCH
responseType - the response Type of the query handler which is matched againstResponseType.NO_MATCH if there is no match, greater than 0 if there is a match. Highest match
should win when choosing a query handler.public Class responseMessagePayloadType()
ResponseTypeClass 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 messagepublic org.reactivestreams.Publisher<R> convert(Object queryResponse)
ResponseTyperesponse of type Object into the type R of this ResponseType instance. Should only be called if ResponseType.matches(Type) returns true. It is
unspecified what this function does if the ResponseType.matches(Type) returned false.queryResponse - the Object to convert into Rresponse of type Rpublic Optional<org.reactivestreams.Publisher<R>> convertExceptional(Throwable e)
ResponseTypeThrowable into the type R of this ResponseType instance.
Used when an error is represented as the message payload. The Optional is not empty when an error is
represented as the message payload.Optional response of type Rpublic ResponseType<?> forSerialization()
ResponseTypeResponseType instance that should be used when serializing responses. This method has a
default implementation that returns this. Implementations that describe a Response Type that is not
suited for serialization, should return an alternative that is suitable, and ensure the ResponseType.convert(Object)
is capable of converting that type of response to the request type in this instance.ResponseType instance describing a type suitable for serializationCopyright © 2010–2023. All rights reserved.