Interface BodyAdapter.Decoder
- All Superinterfaces:
BodyAdapter
- All Known Subinterfaces:
AbstractBodyAdapter.BaseDecoder
- All Known Implementing Classes:
ForwardingDecoder
- Enclosing interface:
BodyAdapter
A
BodyAdapter that decodes response bodies into objects.-
Nested Class Summary
Nested classes/interfaces inherited from interface BodyAdapter
BodyAdapter.Decoder, BodyAdapter.Encoder, BodyAdapter.Hints -
Method Summary
Modifier and TypeMethodDescriptionstatic BodyAdapter.Decoderbasic()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.BodySubscriberthat 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.BodySubscriberthat lazily decodes the response body into an object of the given type using the givenBodyAdapter.Hints.<T> HttpResponse.BodySubscriber<T> Returns aHttpResponse.BodySubscriberthat 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.BodySubscriberthat decodes the response body into an object of the given type using the givenBodyAdapter.Hints.Methods inherited from interface BodyAdapter
isCompatibleWith, supportsType
-
Method Details
-
toObject
Returns aHttpResponse.BodySubscriberthat 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.BodySubscriberthat 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.BodySubscriberthat lazily decodes the response body into an object of the given type using the format specified by the given media type. IfmediaTypeisnull, 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.BodySubscriberthat 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)InputStreamReader(decoded usingMediaType's charset or UTF-8 if absent)byte[]ByteBufferStream<String>(response body lines;MediaType's charset or UTF-8 if absent)ResponsePayload(here the decoder expects to receive theHttpResponse.ResponseInfohint, and anAdapterCodechint 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)
-