Module methanol

Class AbstractBodyAdapter

    • Constructor Detail

      • AbstractBodyAdapter

        protected AbstractBodyAdapter​(MediaType... compatibleMediaTypes)
        Creates an AbstractBodyAdapter compatible with the given media types.
    • Method Detail

      • compatibleMediaTypes

        protected java.util.Set<MediaType> compatibleMediaTypes()
        Returns an immutable set containing the media types this adapter is compatible with.
      • requireSupport

        protected void requireSupport​(TypeRef<?> typeRef)
        Requires that this adapter supports the given type.
        Throws:
        java.lang.UnsupportedOperationException - if this adapter doesn't support the given type.
      • requireSupport

        protected void requireSupport​(java.lang.Class<?> type)
        Requires that this adapter supports the given type.
        Throws:
        java.lang.UnsupportedOperationException - if this adapter doesn't support the given type.
      • requireSupport

        protected void requireSupport​(TypeRef<?> typeRef,
                                      BodyAdapter.Hints hints)
        Requires that this adapter supports the given type and is compatible with the given hints' media type, if any.
        Throws:
        java.lang.UnsupportedOperationException - if this adapter doesn't support the given type or is not compatible with the given hints' media type.
      • requireCompatibleOrNull

        protected void requireCompatibleOrNull​(@Nullable MediaType mediaType)
        Requires that either this adapter is compatible with the given media type, or the given media type is null.
        Throws:
        java.lang.UnsupportedOperationException - if this adapter is not compatible with the given media type.
      • charsetOrDefault

        public static java.nio.charset.Charset charsetOrDefault​(@Nullable MediaType mediaType,
                                                                java.nio.charset.Charset defaultCharset)
        Returns either the result of MediaType.charsetOrDefault(Charset), or the given charset if the given media type is null.
      • attachMediaType

        public static java.net.http.HttpRequest.BodyPublisher attachMediaType​(java.net.http.HttpRequest.BodyPublisher publisher,
                                                                              @Nullable MediaType mediaType)
        Converts the given publisher into a MimeBodyPublisher that has the given media type only if it is not null or has a wildcard, otherwise the given publisher is returned as-is.