- All Superinterfaces:
BodyAdapter
- All Known Subinterfaces:
AbstractBodyAdapter.BaseDecoder
- 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, BodyAdapter.Hints
-
Method Summary
Modifier and TypeMethodDescriptionstatic BodyAdapter.Decoder
basic()
Returns the basic decoder.static Optional
<BodyAdapter.Decoder> getDecoder
(TypeRef<?> typeRef, @Nullable MediaType mediaType) Returns a registered decoder that supports the given object type and media type, if any.static List
<BodyAdapter.Decoder> Returns an immutable list containing the installed decoders.default <T> HttpResponse.BodySubscriber
<Supplier<T>> toDeferredObject
(TypeRef<T> typeRef, @Nullable MediaType mediaType) Returns a completedHttpResponse.BodySubscriber
that lazily decodes the response body into an object of the given type using the format specified by the given media type.default <T> HttpResponse.BodySubscriber
<Supplier<T>> toDeferredObject
(TypeRef<T> typeRef, BodyAdapter.Hints hints) Returns a completedHttpResponse.BodySubscriber
that lazily decodes the response body into an object of the given type using the givenBodyAdapter.Hints
.<T> HttpResponse.BodySubscriber
<T> Returns aHttpResponse.BodySubscriber
that decodes the response body into an object of the given type using the format specified by the given media type.default <T> HttpResponse.BodySubscriber
<T> toObject
(TypeRef<T> typeRef, BodyAdapter.Hints hints) Returns aHttpResponse.BodySubscriber
that decodes the response body into an object of the given type using the givenBodyAdapter.Hints
.Methods inherited from interface com.github.mizosoft.methanol.BodyAdapter
isCompatibleWith, supportsType
-
Method Details
-
toObject
Returns aHttpResponse.BodySubscriber
that decodes the response body into an object of the given type using the format specified by the given media type. If the given media type isnull
, the decoder's default format parameters (e.g., charset) are used.- Throws:
UnsupportedOperationException
- if any of the given type or media type is not supported
-
toObject
Returns aHttpResponse.BodySubscriber
that decodes the response body into an object of the given type using the givenBodyAdapter.Hints
.- Throws:
UnsupportedOperationException
- if any of the given type or hint's media type is not supported
-
toDeferredObject
default <T> HttpResponse.BodySubscriber<Supplier<T>> toDeferredObject(TypeRef<T> typeRef, @Nullable MediaType mediaType) Returns a completedHttpResponse.BodySubscriber
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 uses its default format parameters (e.g., charset).- Throws:
UnsupportedOperationException
- if any of the given type or media type is not supported
-
toDeferredObject
default <T> HttpResponse.BodySubscriber<Supplier<T>> toDeferredObject(TypeRef<T> typeRef, BodyAdapter.Hints hints) Returns a completedHttpResponse.BodySubscriber
that lazily decodes the response body into an object of the given type using the givenBodyAdapter.Hints
.- Throws:
UnsupportedOperationException
- if any of the given type or media type is not supported
-
installed
Returns an immutable list containing the installed decoders. -
getDecoder
Returns a registered decoder that supports the given object type and media type, if any. If the given media type isnull
, any decoder supporting the given object type is returned. -
basic
Returns the basic decoder. The basic decoder is compatible with any media type, and supports decoding:String
(decoded usingMediaType
's charset or UTF-8 if absent)InputStream
Reader
(decoded usingMediaType
's charset or UTF-8 if absent)byte[]
ByteBuffer
Stream<String>
(response body lines;MediaType
's charset or UTF-8 if absent)ResponsePayload
(here the decoder expects to receive theHttpResponse.ResponseInfo
hint, and anAdapterCodec
hint that will be used to convert the payload into the desired type; this is done automatically when sending the request throughMethanol
)Publisher<List<ByteBuffer>>
(a replaying publisher for the response body)Void
(discards the response body)
-