Module methanol
Package com.github.mizosoft.methanol
Class Methanol.BaseBuilder<B extends Methanol.BaseBuilder<B>>
- java.lang.Object
-
- com.github.mizosoft.methanol.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.ObjectA baseMethanolbuilder allowing to set the non-standard properties.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description BadapterCodec(AdapterCodec adapterCodec)Specifies theAdapterCodecwith which request and response payloads are mapped.Bapply(java.util.function.Consumer<? super B> consumer)Calls the given consumer against this builder.BautoAcceptEncoding(boolean autoAcceptEncoding)If enabled, each request will have anAccept-Encodingheader appended, the value of which is the set ofsupported encodings.BbackendInterceptor(Methanol.Interceptor interceptor)Adds an interceptor that is invoked right before the request is forwarded to the client's backend.BbaseUri(java.lang.String uri)Sets the baseURIwith which each outgoing requests'URIisresolved.BbaseUri(java.net.URI uri)Sets the baseURIwith which each outgoing requests'URIisresolved.Methanolbuild()Creates a newMethanolinstance.BdefaultHeader(java.lang.String name, java.lang.String value)Adds the given default header.BdefaultHeaders(java.lang.String... headers)Adds each of the given default headers.BdefaultHeaders(java.util.function.Consumer<HeadersAccumulator<?>> configurator)Configures the default headers as specified by the given consumer.BheadersTimeout(java.time.Duration headersTimeout)Sets a timeout that will raise anHttpHeadersTimeoutExceptionif all response headers aren't received within the timeout.BheadersTimeout(java.time.Duration headersTimeout, java.util.concurrent.ScheduledExecutorService scheduler)Same asheadersTimeout(Duration)but specifies aScheduledExecutorServiceto use for scheduling timeout events.Binterceptor(Methanol.Interceptor interceptor)Adds an interceptor that is invoked right after the client receives a request.BpostDecorationInterceptor(Methanol.Interceptor interceptor)Deprecated.BreadTimeout(java.time.Duration readTimeout)Sets aread timeoutthat is applied to every request.BreadTimeout(java.time.Duration readTimeout, java.util.concurrent.ScheduledExecutorService scheduler)Sets a defaultreadtimeoutthat is applied to very request, using the givenScheduledExecutorServicefor scheduling timeout events.BrequestTimeout(java.time.Duration requestTimeout)Sets a defaultrequest timeoutto use on every request when no timeout is explicitly set on anHttpRequest.Builder.BuserAgent(java.lang.String userAgent)Sets a defaultUser-Agentheader to use when sending requests.
-
-
-
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 defaultUser-Agentheader to use when sending requests.- Throws:
java.lang.IllegalArgumentException- ifuserAgentis an invalid header value
-
baseUri
@CanIgnoreReturnValue public B baseUri(java.lang.String uri)
Sets the baseURIwith which each outgoing requests'URIisresolved.
-
baseUri
@CanIgnoreReturnValue public B baseUri(java.net.URI uri)
Sets the baseURIwith which each outgoing requests'URIisresolved.
-
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 defaultrequest timeoutto use on every request when no timeout is explicitly set on anHttpRequest.Builder.
-
headersTimeout
@CanIgnoreReturnValue public B headersTimeout(java.time.Duration headersTimeout)
Sets a timeout that will raise anHttpHeadersTimeoutExceptionif all response headers aren't received within the timeout. Timeout events are scheduled using a system-wideScheduledExecutorService.
-
headersTimeout
@CanIgnoreReturnValue public B headersTimeout(java.time.Duration headersTimeout, java.util.concurrent.ScheduledExecutorService scheduler)
Same asheadersTimeout(Duration)but specifies aScheduledExecutorServiceto use for scheduling timeout events.
-
readTimeout
@CanIgnoreReturnValue public B readTimeout(java.time.Duration readTimeout)
Sets aread timeoutthat is applied to every request. Timeout events are scheduled using a system-wideScheduledExecutorService.
-
readTimeout
@CanIgnoreReturnValue public B readTimeout(java.time.Duration readTimeout, java.util.concurrent.ScheduledExecutorService scheduler)
Sets a defaultreadtimeoutthat is applied to very request, using the givenScheduledExecutorServicefor scheduling timeout events.
-
adapterCodec
@CanIgnoreReturnValue public B adapterCodec(AdapterCodec adapterCodec)
Specifies theAdapterCodecwith which request and response payloads are mapped.
-
autoAcceptEncoding
@CanIgnoreReturnValue public B autoAcceptEncoding(boolean autoAcceptEncoding)
If enabled, each request will have anAccept-Encodingheader appended, the value of which is the set ofsupported encodings. Additionally, each received response will be transparently decompressed by wrapping itsBodyHandlerwithMoreBodyHandlers.decoding(BodyHandler).This value is
trueby 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 (itsURIresolved with the baseURI, default headers added, etc...) or handled by anHttpCache.
-
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 allclient interceptors, is decorated (itsURIresolved with the baseURI, default headers added, etc...) and finally handled by anHttpCache. This implies that backend interceptors aren't called if network isn't used, normally due to the presence of anHttpCachethat 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)
Deprecated.
-
build
public Methanol build()
Creates a newMethanolinstance.
-
-