Module methanol

Class Methanol.BaseBuilder<B extends Methanol.BaseBuilder<B>>

  • Direct Known Subclasses:
    Methanol.Builder, Methanol.WithClientBuilder
    Enclosing class:
    Methanol

    public abstract static class Methanol.BaseBuilder<B extends Methanol.BaseBuilder<B>>
    extends java.lang.Object
    A base Methanol builder allowing to set the non-standard properties.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      B adapterCodec​(AdapterCodec adapterCodec)
      Specifies the AdapterCodec with which request and response payloads are mapped.
      B apply​(java.util.function.Consumer<? super B> consumer)
      Calls the given consumer against this builder.
      B autoAcceptEncoding​(boolean autoAcceptEncoding)
      If enabled, each request will have an Accept-Encoding header appended, the value of which is the set of supported encodings.
      B backendInterceptor​(Methanol.Interceptor interceptor)
      Adds an interceptor that is invoked right before the request is forwarded to the client's backend.
      B baseUri​(java.lang.String uri)
      Sets the base URI with which each outgoing requests' URI is resolved.
      B baseUri​(java.net.URI uri)
      Sets the base URI with which each outgoing requests' URI is resolved.
      Methanol build()
      Creates a new Methanol instance.
      B defaultHeader​(java.lang.String name, java.lang.String value)
      Adds the given default header.
      B defaultHeaders​(java.lang.String... headers)
      Adds each of the given default headers.
      B defaultHeaders​(java.util.function.Consumer<HeadersAccumulator<?>> configurator)
      Configures the default headers as specified by the given consumer.
      B headersTimeout​(java.time.Duration headersTimeout)
      Sets a timeout that will raise an HttpHeadersTimeoutException if all response headers aren't received within the timeout.
      B headersTimeout​(java.time.Duration headersTimeout, java.util.concurrent.ScheduledExecutorService scheduler)
      Same as headersTimeout(Duration) but specifies a ScheduledExecutorService to use for scheduling timeout events.
      B interceptor​(Methanol.Interceptor interceptor)
      Adds an interceptor that is invoked right after the client receives a request.
      B postDecorationInterceptor​(Methanol.Interceptor interceptor)
      B readTimeout​(java.time.Duration readTimeout)
      Sets a read timeout that is applied to every request.
      B readTimeout​(java.time.Duration readTimeout, java.util.concurrent.ScheduledExecutorService scheduler)
      Sets a default readtimeout that is applied to very request, using the given ScheduledExecutorService for scheduling timeout events.
      B requestTimeout​(java.time.Duration requestTimeout)
      Sets a default request timeout to use on every request when no timeout is explicitly set on an HttpRequest.Builder.
      B userAgent​(java.lang.String userAgent)
      Sets a default User-Agent header to use when sending requests.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • apply

        @CanIgnoreReturnValue
        public final B apply​(java.util.function.Consumer<? super B> consumer)
        Calls the given consumer against this builder.
      • userAgent

        @CanIgnoreReturnValue
        public B userAgent​(java.lang.String userAgent)
        Sets a default User-Agent header to use when sending requests.
        Throws:
        java.lang.IllegalArgumentException - if userAgent is an invalid header value
      • baseUri

        @CanIgnoreReturnValue
        public B baseUri​(java.lang.String uri)
        Sets the base URI with which each outgoing requests' URI is resolved.
      • baseUri

        @CanIgnoreReturnValue
        public B baseUri​(java.net.URI uri)
        Sets the base URI with which each outgoing requests' URI is resolved.
      • defaultHeader

        @CanIgnoreReturnValue
        public B defaultHeader​(java.lang.String name,
                               java.lang.String value)
        Adds the given default header.
      • defaultHeaders

        @CanIgnoreReturnValue
        public B defaultHeaders​(java.lang.String... headers)
        Adds each of the given default headers.
      • defaultHeaders

        @CanIgnoreReturnValue
        public B defaultHeaders​(java.util.function.Consumer<HeadersAccumulator<?>> configurator)
        Configures the default headers as specified by the given consumer.
      • requestTimeout

        @CanIgnoreReturnValue
        public B requestTimeout​(java.time.Duration requestTimeout)
        Sets a default request timeout to use on every request when no timeout is explicitly set on an HttpRequest.Builder.
      • headersTimeout

        @CanIgnoreReturnValue
        public B headersTimeout​(java.time.Duration headersTimeout)
        Sets a timeout that will raise an HttpHeadersTimeoutException if all response headers aren't received within the timeout. Timeout events are scheduled using a system-wide ScheduledExecutorService.
      • headersTimeout

        @CanIgnoreReturnValue
        public B headersTimeout​(java.time.Duration headersTimeout,
                                java.util.concurrent.ScheduledExecutorService scheduler)
        Same as headersTimeout(Duration) but specifies a ScheduledExecutorService to use for scheduling timeout events.
      • readTimeout

        @CanIgnoreReturnValue
        public B readTimeout​(java.time.Duration readTimeout)
        Sets a read timeout that is applied to every request. Timeout events are scheduled using a system-wide ScheduledExecutorService.
      • readTimeout

        @CanIgnoreReturnValue
        public B readTimeout​(java.time.Duration readTimeout,
                             java.util.concurrent.ScheduledExecutorService scheduler)
        Sets a default readtimeout that is applied to very request, using the given ScheduledExecutorService for scheduling timeout events.
      • adapterCodec

        @CanIgnoreReturnValue
        public B adapterCodec​(AdapterCodec adapterCodec)
        Specifies the AdapterCodec with which request and response payloads are mapped.
      • autoAcceptEncoding

        @CanIgnoreReturnValue
        public B autoAcceptEncoding​(boolean autoAcceptEncoding)
        If enabled, each request will have an Accept-Encoding header appended, the value of which is the set of supported encodings. Additionally, each received response will be transparently decompressed by wrapping its BodyHandler with MoreBodyHandlers.decoding(BodyHandler).

        This value is true by default.

      • interceptor

        @CanIgnoreReturnValue
        public B interceptor​(Methanol.Interceptor interceptor)
        Adds an interceptor that is invoked right after the client receives a request. The interceptor receives the request before it is decorated (its URI resolved with the base URI, default headers added, etc...) or handled by an HttpCache.
      • backendInterceptor

        @CanIgnoreReturnValue
        public B backendInterceptor​(Methanol.Interceptor interceptor)
        Adds an interceptor that is invoked right before the request is forwarded to the client's backend. The interceptor receives the request after it is handled by all client interceptors, is decorated (its URI resolved with the base URI, default headers added, etc...) and finally handled by an HttpCache. This implies that backend interceptors aren't called if network isn't used, normally due to the presence of an HttpCache that is capable of serving a stored response.
      • postDecorationInterceptor

        @CanIgnoreReturnValue
        @Deprecated(since="1.5.0")
        @InlineMe(replacement="this.backendInterceptor(interceptor)")
        public final B postDecorationInterceptor​(Methanol.Interceptor interceptor)
      • build

        public Methanol build()
        Creates a new Methanol instance.