Package com.linecorp.armeria.client
Class JsonConditionalResponseAs<T>
java.lang.Object
com.linecorp.armeria.client.JsonConditionalResponseAs<T>
Provides a way for users to add
ResponseAs
mappings to transform an aggregated response
given that the corresponding Predicate
is satisfied. Note that the conditionals are
invoked in the order in which they are added.
RestClient.of(...)
.get("/")
.execute(
ResponseAs.<MyResponse>json(MyMessage.class, res -> res.status().isError())
.orElseJson(EmptyMessage.class, res -> res.status().isInformational())
.orElseJson(MyError.class)).join();
-
Method Summary
Modifier and TypeMethodDescriptionorElseJson
(TypeReference<? extends T> typeRef) ReturnsFutureResponseAs
that deserializes theHttpResponse
based on the configured deserializers so far and deserializes to theTypeReference
lastly if none of thePredicate
of configured deserializers pass.orElseJson
(TypeReference<? extends T> typeRef, ObjectMapper objectMapper) ReturnsFutureResponseAs
that deserializes theHttpResponse
based on the configured deserializers so far and deserializes to theTypeReference
lastly using theObjectMapper
if none of thePredicate
of configured deserializers pass.orElseJson
(TypeReference<? extends T> typeRef, ObjectMapper objectMapper, Predicate<AggregatedHttpResponse> predicate) Sets thePredicate
andTypeReference
that the content is deserialized into theTypeReference
using theObjectMapper
when theAggregatedHttpResponse
passes thePredicate
.orElseJson
(TypeReference<? extends T> typeRef, Predicate<AggregatedHttpResponse> predicate) Sets thePredicate
andTypeReference
that the content is deserialized into theTypeReference
when theAggregatedHttpResponse
passes thePredicate
.orElseJson
(Class<? extends T> clazz) ReturnsFutureResponseAs
that deserializes theHttpResponse
based on the configured deserializers so far and deserializes to theClass
lastly if none of thePredicate
of configured deserializers pass.orElseJson
(Class<? extends T> clazz, ObjectMapper objectMapper) ReturnsFutureResponseAs
that deserializes theHttpResponse
based on the configured deserializers so far and deserializes to theClass
lastly using theObjectMapper
if none of thePredicate
of configured deserializers pass.orElseJson
(Class<? extends T> clazz, ObjectMapper objectMapper, Predicate<AggregatedHttpResponse> predicate) Sets thePredicate
andClass
that the content is deserialized into theClass
using theObjectMapper
when theAggregatedHttpResponse
passes thePredicate
.orElseJson
(Class<? extends T> clazz, Predicate<AggregatedHttpResponse> predicate) Sets thePredicate
andClass
that the content is deserialized into theClass
when theAggregatedHttpResponse
passes thePredicate
.
-
Method Details
-
orElseJson
public JsonConditionalResponseAs<T> orElseJson(Class<? extends T> clazz, Predicate<AggregatedHttpResponse> predicate) Sets thePredicate
andClass
that the content is deserialized into theClass
when theAggregatedHttpResponse
passes thePredicate
. -
orElseJson
public JsonConditionalResponseAs<T> orElseJson(Class<? extends T> clazz, ObjectMapper objectMapper, Predicate<AggregatedHttpResponse> predicate) Sets thePredicate
andClass
that the content is deserialized into theClass
using theObjectMapper
when theAggregatedHttpResponse
passes thePredicate
. -
orElseJson
public JsonConditionalResponseAs<T> orElseJson(TypeReference<? extends T> typeRef, Predicate<AggregatedHttpResponse> predicate) Sets thePredicate
andTypeReference
that the content is deserialized into theTypeReference
when theAggregatedHttpResponse
passes thePredicate
. -
orElseJson
public JsonConditionalResponseAs<T> orElseJson(TypeReference<? extends T> typeRef, ObjectMapper objectMapper, Predicate<AggregatedHttpResponse> predicate) Sets thePredicate
andTypeReference
that the content is deserialized into theTypeReference
using theObjectMapper
when theAggregatedHttpResponse
passes thePredicate
. -
orElseJson
ReturnsFutureResponseAs
that deserializes theHttpResponse
based on the configured deserializers so far and deserializes to theClass
lastly if none of thePredicate
of configured deserializers pass. -
orElseJson
public FutureResponseAs<ResponseEntity<T>> orElseJson(Class<? extends T> clazz, ObjectMapper objectMapper) ReturnsFutureResponseAs
that deserializes theHttpResponse
based on the configured deserializers so far and deserializes to theClass
lastly using theObjectMapper
if none of thePredicate
of configured deserializers pass. -
orElseJson
ReturnsFutureResponseAs
that deserializes theHttpResponse
based on the configured deserializers so far and deserializes to theTypeReference
lastly if none of thePredicate
of configured deserializers pass. -
orElseJson
public FutureResponseAs<ResponseEntity<T>> orElseJson(TypeReference<? extends T> typeRef, ObjectMapper objectMapper) ReturnsFutureResponseAs
that deserializes theHttpResponse
based on the configured deserializers so far and deserializes to theTypeReference
lastly using theObjectMapper
if none of thePredicate
of configured deserializers pass.
-