Interface BodyAdapter.Encoder
- All Superinterfaces:
BodyAdapter
- All Known Subinterfaces:
AbstractBodyAdapter.BaseEncoder
- All Known Implementing Classes:
ForwardingEncoder
- Enclosing interface:
BodyAdapter
A
BodyAdapter that encodes objects into request bodies.-
Nested Class Summary
Nested classes/interfaces inherited from interface BodyAdapter
BodyAdapter.Decoder, BodyAdapter.Encoder, BodyAdapter.Hints -
Method Summary
Modifier and TypeMethodDescriptionstatic BodyAdapter.Encoderbasic()Returns the basic encoder.static Optional<BodyAdapter.Encoder> getEncoder(TypeRef<?> typeRef, @Nullable MediaType mediaType) Returns a registered encoder that supports the given object type and media type, if any.static List<BodyAdapter.Encoder> Returns an immutable list containing the installed encoders.Returns aHttpRequest.BodyPublisherthat encodes the given object into a request body using the format specified by the given media type.default <T> HttpRequest.BodyPublishertoBody(T value, TypeRef<T> typeRef, BodyAdapter.Hints hints) Returns aHttpRequest.BodyPublisherthat encodes the given object into a request body based on the givenTypeRef, using the given hintsBodyAdapter.Hintsfor encoder-specific customization.Methods inherited from interface BodyAdapter
isCompatibleWith, supportsType
-
Method Details
-
toBody
Returns aHttpRequest.BodyPublisherthat encodes the given object into a request body using the format specified by the given media type. If the given media type isnull, the encoder uses its default format parameters (e.g., charset).- Throws:
UnsupportedOperationException- if the given object's runtime type or the given media type is not supported
-
toBody
Returns aHttpRequest.BodyPublisherthat encodes the given object into a request body based on the givenTypeRef, using the given hintsBodyAdapter.Hintsfor encoder-specific customization.- Throws:
UnsupportedOperationException- if any of the given type or hints' media type is not supportedIllegalArgumentException- if the given object is not an instance of the given type
-
installed
Returns an immutable list containing the installed encoders. -
getEncoder
Returns a registered encoder that supports the given object type and media type, if any. If the given media type isnull, any encoder supporting the given object type is returned. -
basic
Returns the basic encoder. The basic encoder is compatible with any media type, and supports encoding any subtype of:CharSequence(encoded usingMediaType's charset or UTF-8 if absent)InputStreambyte[]ByteBufferPath(represents a file from which the request content is sent)Supplier<? extends InputStream>Iterable<byte[]>
-