Module methanol

Interface BodyAdapter.Encoder

    • Method Detail

      • toBody

        java.net.http.HttpRequest.BodyPublisher toBody​(java.lang.Object value,
                                                       @Nullable MediaType mediaType)
        Returns a HttpRequest.BodyPublisher that encodes the given object into a request body using the format specified by the given media type. If the given media type is null, the encoder uses its default format parameters (e.g., charset).
        Throws:
        java.lang.UnsupportedOperationException - if the given object's runtime type or the given media type is not supported
      • toBody

        default <T> java.net.http.HttpRequest.BodyPublisher toBody​(T value,
                                                                   TypeRef<T> typeRef,
                                                                   BodyAdapter.Hints hints)
        Returns a HttpRequest.BodyPublisher that encodes the given object into a request body based on the given TypeRef, using the given hints BodyAdapter.Hints for encoder-specific customization.
        Throws:
        java.lang.UnsupportedOperationException - if any of the given type or hints' media type is not supported
        java.lang.IllegalArgumentException - if the given object is not an instance of the given type
      • installed

        static java.util.List<BodyAdapter.Encoder> installed()
        Returns an immutable list containing the installed encoders.
      • getEncoder

        static java.util.Optional<BodyAdapter.Encoder> getEncoder​(TypeRef<?> typeRef,
                                                                  @Nullable MediaType mediaType)
        Returns a registered encoder that supports the given object type and media type, if any. If the given media type is null, any encoder supporting the given object type is returned.
      • basic

        static BodyAdapter.Encoder basic()
        Returns the basic encoder. The basic encoder is compatible with any media type, and supports encoding any subtype of:
        • CharSequence (encoded using MediaType'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[]>