- All Superinterfaces:
BodyAdapter
- All Known Implementing Classes:
ForwardingDecoder
,StringDecoder
- Enclosing interface:
BodyAdapter
A
BodyAdapter
that decodes response bodies into objects.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.github.mizosoft.methanol.BodyAdapter
BodyAdapter.Decoder, BodyAdapter.Encoder
-
Method Summary
Modifier and TypeMethodDescriptionstatic Optional
<BodyAdapter.Decoder> getDecoder
(TypeRef<?> objectType, @Nullable MediaType mediaType) Returns anOptional
containing aDecoder
that supports the given object type and media type.static List
<BodyAdapter.Decoder> Returns an immutable list containing the installed decoders.default <T> HttpResponse.BodySubscriber
<Supplier<T>> toDeferredObject
(TypeRef<T> objectType, @Nullable MediaType mediaType) Returns a completedBodySubscriber
that lazily decodes the response body into an object of the given type using the format specified by the given media type.<T> HttpResponse.BodySubscriber
<T> Returns aBodySubscriber
that decodes the response body into an object of the given type using the format specified by the given media type.Methods inherited from interface com.github.mizosoft.methanol.BodyAdapter
isCompatibleWith, supportsType
-
Method Details
-
toObject
Returns aBodySubscriber
that decodes the response body into an object of the given type using the format specified by the given media type. IfmediaType
isnull
, the decoder's default format parameters (e.g. charset) are used. -
toDeferredObject
default <T> HttpResponse.BodySubscriber<Supplier<T>> toDeferredObject(TypeRef<T> objectType, @Nullable MediaType mediaType) Returns a completedBodySubscriber
that lazily decodes the response body into an object of the given type using the format specified by the given media type. IfmediaType
isnull
, the decoder's default format parameters (e.g. charset) are used.The default implementation returns a subscriber completed with a supplier that blocks ,uninterruptedly, on the subscriber returned by
toObject(TypeRef, MediaType)
. Any completion exception raised while blocking is rethrown from the supplier as aCompletionException
. Encoders that support reading from a blocking source should override this method to defer reading from such a source until the supplier is called. -
installed
Returns an immutable list containing the installed decoders. -
getDecoder
static Optional<BodyAdapter.Decoder> getDecoder(TypeRef<?> objectType, @Nullable MediaType mediaType) Returns anOptional
containing aDecoder
that supports the given object type and media type. IfmediaType
isnull
, any decoder supporting the given object type is returned.
-