- All Superinterfaces:
BodyAdapter
- All Known Subinterfaces:
AbstractBodyAdapter.BaseEncoder
- All Known Implementing Classes:
CharSequenceEncoder
,ForwardingEncoder
- Enclosing interface:
BodyAdapter
A
BodyAdapter
that encodes objects into request bodies.-
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.Encoder
basic()
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.BodyPublisher
that encodes the given object into a request body using the format specified by the given media type.default <T> HttpRequest.BodyPublisher
toBody
(T value, TypeRef<T> typeRef, BodyAdapter.Hints hints) Returns aHttpRequest.BodyPublisher
that encodes the given object into a request body based on the givenTypeRef
, using the given hintsBodyAdapter.Hints
for encoder-specific customization.Methods inherited from interface com.github.mizosoft.methanol.BodyAdapter
isCompatibleWith, supportsType
-
Method Details
-
toBody
Returns aHttpRequest.BodyPublisher
that 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.BodyPublisher
that encodes the given object into a request body based on the givenTypeRef
, using the given hintsBodyAdapter.Hints
for 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)InputStream
byte[]
ByteBuffer
Path
(represents a file from which the request content is sent)Supplier<? extends InputStream>
Iterable<byte[]>
-