org.apache.juneau.rest.client.RestClientBuilder Maven / Gradle / Ivy
// ***************************************************************************************************************************
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
// * with the License. You may obtain a copy of the License at *
// * *
// * http://www.apache.org/licenses/LICENSE-2.0 *
// * *
// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
package org.apache.juneau.rest.client;
import static org.apache.juneau.internal.StringUtils.*;
import static org.apache.juneau.parser.InputStreamParser.*;
import static org.apache.juneau.parser.ReaderParser.*;
import static org.apache.juneau.rest.client.RestClient.*;
import static org.apache.juneau.BeanTraverseContext.*;
import static org.apache.juneau.serializer.OutputStreamSerializer.*;
import static org.apache.juneau.serializer.WriterSerializer.*;
import static org.apache.juneau.uon.UonSerializer.*;
import java.lang.reflect.*;
import java.net.*;
import java.security.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.logging.*;
import javax.net.ssl.*;
import org.apache.http.*;
import org.apache.http.auth.*;
import org.apache.http.client.*;
import org.apache.http.client.CookieStore;
import org.apache.http.client.config.*;
import org.apache.http.client.entity.*;
import org.apache.http.config.*;
import org.apache.http.conn.*;
import org.apache.http.conn.routing.*;
import org.apache.http.conn.socket.*;
import org.apache.http.conn.ssl.*;
import org.apache.http.conn.util.*;
import org.apache.http.cookie.*;
import org.apache.http.impl.client.*;
import org.apache.http.impl.conn.*;
import org.apache.http.protocol.*;
import org.apache.juneau.*;
import org.apache.juneau.html.*;
import org.apache.juneau.http.*;
import org.apache.juneau.httppart.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.json.*;
import org.apache.juneau.msgpack.*;
import org.apache.juneau.oapi.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.plaintext.*;
import org.apache.juneau.rest.client.mock.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.uon.*;
import org.apache.juneau.urlencoding.*;
import org.apache.juneau.utils.*;
import org.apache.juneau.xml.*;
/**
* Builder class for the {@link RestClient} class.
*
*
* Instances of this class are created by the following methods:
*
* - {@link RestClient#create()} - Create from scratch.
*
- {@link RestClient#create(Serializer,Parser)} - Create from scratch using specified serializer/parser.
*
- {@link RestClient#create(Class,Class)} - Create from scratch using specified serializer/parser classes.
*
- {@link RestClient#builder()} - Copy settings from an existing client.
*
*
* See Also:
*
* - {@doc juneau-rest-client}
*
*/
public class RestClientBuilder extends BeanContextBuilder {
private HttpClientConnectionManager httpClientConnectionManager;
private HttpClientBuilder httpClientBuilder;
private CloseableHttpClient httpClient;
private boolean enableSsl = false;
private HostnameVerifier hostnameVerifier;
private KeyManager[] keyManagers;
private TrustManager[] trustManagers;
private SecureRandom secureRandom;
private String[] sslProtocols, cipherSuites;
private boolean pooled;
/**
* Constructor.
* @param ps
* Initial configuration properties for this builder.
*
Can be null .
* @param httpClientBuilder
* The HTTP client builder to use for this REST client builder.
*
Can be null to just call {@link #createHttpClientBuilder()} to instantiate it again.
*/
protected RestClientBuilder(PropertyStore ps, HttpClientBuilder httpClientBuilder) {
super(ps);
this.httpClientBuilder = httpClientBuilder != null ? httpClientBuilder : createHttpClientBuilder();
}
@SuppressWarnings("resource")
@Override /* ContextBuilder */
public RestClient build() {
try {
CloseableHttpClient c = httpClient != null ? httpClient : createHttpClient();
PropertyStore ps = psb.build();
return new RestClient(ps, httpClientBuilder, c);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Convenience method for specifying JSON as the transmission media type.
*
*
* Identical to calling serializer(JsonSerializer.class ).parser(JsonParser.class )
.
*
* @return This object (for method chaining).
*/
public RestClientBuilder json() {
return serializer(JsonSerializer.class).parser(JsonParser.class);
}
/**
* Convenience method for specifying Simple JSON as the transmission media type.
*
*
* Identical to calling serializer(SimpleJsonSerializer.class ).parser(JsonParser.class )
.
*
* @return This object (for method chaining).
*/
public RestClientBuilder simpleJson() {
return serializer(SimpleJsonSerializer.class).parser(JsonParser.class);
}
/**
* Convenience method for specifying XML as the transmission media type.
*
*
* Identical to calling serializer(XmlSerializer.class ).parser(XmlParser.class )
.
*
* @return This object (for method chaining).
*/
public RestClientBuilder xml() {
return serializer(XmlSerializer.class).parser(XmlParser.class);
}
/**
* Convenience method for specifying HTML as the transmission media type.
*
*
* Identical to calling serializer(HtmlSerializer.class ).parser(HtmlParser.class )
.
*
* @return This object (for method chaining).
*/
public RestClientBuilder html() {
return serializer(HtmlSerializer.class).parser(HtmlParser.class);
}
/**
* Convenience method for specifying plain-text as the transmission media type.
*
*
* Identical to calling serializer(PlainTextSerializer.class ).parser(PlainTextParser.class )
.
*
* @return This object (for method chaining).
*/
public RestClientBuilder plainText() {
return serializer(PlainTextSerializer.class).parser(PlainTextParser.class);
}
/**
* Convenience method for specifying MessagePack as the transmission media type.
*
*
* Identical to calling serializer(MsgPackSerializer.class ).parser(MsgPackParser.class )
.
*
* @return This object (for method chaining).
*/
public RestClientBuilder msgpack() {
return serializer(MsgPackSerializer.class).parser(MsgPackParser.class);
}
/**
* Convenience method for specifying UON as the transmission media type.
*
*
* Identical to calling serializer(UonSerializer.class ).parser(UonParser.class )
.
*
* @return This object (for method chaining).
*/
public RestClientBuilder uon() {
return serializer(UonSerializer.class).parser(UonParser.class);
}
/**
* Convenience method for specifying URL-Encoding as the transmission media type.
*
*
* Identical to calling serializer(UrlEncodingSerializer.class ).parser(UrlEncodingParser.class )
.
*
* @return This object (for method chaining).
*/
public RestClientBuilder urlEnc() {
return serializer(UrlEncodingSerializer.class).parser(UrlEncodingParser.class);
}
/**
* Convenience method for specifying URL-Encoding as the transmission media type.
*
*
* Identical to calling serializer(OpenApiSerializer.class ).parser(OpenApiParser.class )
.
*
* @return This object (for method chaining).
*/
public RestClientBuilder openapi() {
return serializer(OpenApiSerializer.class).parser(OpenApiParser.class);
}
/**
* Creates an instance of an {@link HttpClient} to be used to handle all HTTP communications with the target server.
*
*
* This HTTP client is used when the HTTP client is not specified through one of the constructors or the
* {@link #httpClient(CloseableHttpClient, boolean)} method.
*
*
* Subclasses can override this method to provide specially-configured HTTP clients to handle stuff such as
* SSL/TLS certificate handling, authentication, etc.
*
*
* The default implementation returns an instance of {@link HttpClient} using the client builder returned by
* {@link #createHttpClientBuilder()}.
*
* @return The HTTP client to use.
* @throws Exception
*/
protected CloseableHttpClient createHttpClient() throws Exception {
// Don't call createConnectionManager() if RestClient.setConnectionManager() was called.
if (httpClientConnectionManager == null)
httpClientBuilder.setConnectionManager(createConnectionManager());
else
httpClientBuilder.setConnectionManager(httpClientConnectionManager);
return httpClientBuilder.build();
}
/**
* Creates an instance of an {@link HttpClientBuilder} to be used to create the {@link HttpClient}.
*
*
* Subclasses can override this method to provide their own client builder.
*
*
* The predefined method returns an {@link HttpClientBuilder} with the following settings:
*
* - Lax redirect strategy.
*
- The connection manager returned by {@link #createConnectionManager()}.
*
*
* @return The HTTP client builder to use to create the HTTP client.
*/
protected HttpClientBuilder createHttpClientBuilder() {
HttpClientBuilder b = HttpClientBuilder.create();
b.setRedirectStrategy(new AllowAllRedirects());
return b;
}
/**
* Creates the {@link HttpClientConnectionManager} returned by {@link #createConnectionManager()}.
*
*
* Subclasses can override this method to provide their own connection manager.
*
*
* The default implementation returns an instance of a {@link PoolingHttpClientConnectionManager}.
*
* @return The HTTP client builder to use to create the HTTP client.
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
@SuppressWarnings("resource")
protected HttpClientConnectionManager createConnectionManager() throws KeyManagementException, NoSuchAlgorithmException {
if (enableSsl) {
HostnameVerifier hv = hostnameVerifier != null ? hostnameVerifier : new DefaultHostnameVerifier();
TrustManager[] tm = trustManagers;
String[] sslp = sslProtocols == null ? getDefaultProtocols() : sslProtocols;
SecureRandom sr = secureRandom;
KeyManager[] km = keyManagers;
String[] cs = cipherSuites;
RegistryBuilder rb = RegistryBuilder.create();
rb.register("http", PlainConnectionSocketFactory.getSocketFactory());
SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom().build();
sslContext.init(km, tm, sr);
SSLConnectionSocketFactory sslcsf = new SSLConnectionSocketFactory(sslContext, sslp, cs, hv);
rb.register("https", sslcsf).build();
return (pooled ? new PoolingHttpClientConnectionManager(rb.build()) : new BasicHttpClientConnectionManager(rb.build()));
}
// Using pooling connection so that this client is threadsafe.
return (pooled ? new PoolingHttpClientConnectionManager() : new BasicHttpClientConnectionManager());
}
/**
* Enable SSL support on this client.
*
*
* Used in conjunction with the following methods for setting up SSL parameters:
*
* - {@link #sslProtocols(String...)}
*
- {@link #cipherSuites(String...)}
*
- {@link #hostnameVerifier(HostnameVerifier)}
*
- {@link #keyManagers(KeyManager...)}
*
- {@link #trustManagers(TrustManager...)}
*
- {@link #secureRandom(SecureRandom)}
*
*
* @return This object (for method chaining).
* @throws KeyStoreException
* @throws NoSuchAlgorithmException
*/
public RestClientBuilder enableSSL() throws KeyStoreException, NoSuchAlgorithmException {
this.enableSsl = true;
return this;
}
/**
* Enable LARestClientBuilder SSL support.
*
*
* Same as calling the following:
*
* builder
* .enableSSL()
* .hostnameVerifier(new NoopHostnameVerifier())
* .trustManagers(new SimpleX509TrustManager(true ));
*
*
* @return This object (for method chaining).
* @throws KeyStoreException
* @throws NoSuchAlgorithmException
*/
public RestClientBuilder enableLaxSSL() throws KeyStoreException, NoSuchAlgorithmException {
this.enableSsl = true;
hostnameVerifier(new NoopHostnameVerifier());
trustManagers(new SimpleX509TrustManager(true));
return this;
}
/**
* Supported SSL protocols.
*
*
* This is the value passed to the supportedProtocols
parameter of the
* {@link SSLConnectionSocketFactory#SSLConnectionSocketFactory(SSLContext,String[],String[],HostnameVerifier)}
* constructor.
*
*
* The default value is taken from the system property "transport.client.protocol" .
*
If system property is not defined, defaults to {"SSL_TLS" ,"TLS" ,"SSL" }
.
*
*
* This method is effectively ignored if {@link #enableSSL()} has not been called or the client connection manager
* has been defined via {@link #httpClientConnectionManager(HttpClientConnectionManager)}.
*
* @param sslProtocols The supported SSL protocols.
* @return This object (for method chaining).
*/
public RestClientBuilder sslProtocols(String...sslProtocols) {
this.sslProtocols = sslProtocols;
return this;
}
/**
* Supported cipher suites.
*
*
* This is the value passed to the supportedCipherSuites
parameter of the
* {@link SSLConnectionSocketFactory#SSLConnectionSocketFactory(SSLContext,String[],String[],HostnameVerifier)}
* constructor.
*
*
* The default value is null .
*
*
* This method is effectively ignored if {@link #enableSSL()} has not been called or the client connection manager
* has been defined via {@link #httpClientConnectionManager(HttpClientConnectionManager)}.
*
* @param cipherSuites The supported cipher suites.
* @return This object (for method chaining).
*/
public RestClientBuilder cipherSuites(String...cipherSuites) {
this.cipherSuites = cipherSuites;
return this;
}
/**
* Hostname verifier.
*
*
* This is the value passed to the hostnameVerifier
parameter of the
* {@link SSLConnectionSocketFactory#SSLConnectionSocketFactory(SSLContext,String[],String[],HostnameVerifier)}
* constructor.
*
*
* The default value is null .
*
*
* This method is effectively ignored if {@link #enableSSL()} has not been called or the client connection manager
* has been defined via {@link #httpClientConnectionManager(HttpClientConnectionManager)}.
*
* @param hostnameVerifier The hostname verifier.
* @return This object (for method chaining).
*/
public RestClientBuilder hostnameVerifier(HostnameVerifier hostnameVerifier) {
this.hostnameVerifier = hostnameVerifier;
return this;
}
/**
* Key managers.
*
*
* This is the value passed to the keyManagers
parameter of the
* {@link SSLContext#init(KeyManager[],TrustManager[],SecureRandom)} method.
*
*
* The default value is null .
*
*
* This method is effectively ignored if {@link #enableSSL()} has not been called or the client connection manager
* has been defined via {@link #httpClientConnectionManager(HttpClientConnectionManager)}.
*
* @param keyManagers The key managers.
* @return This object (for method chaining).
*/
public RestClientBuilder keyManagers(KeyManager...keyManagers) {
this.keyManagers = keyManagers;
return this;
}
/**
* Trust managers.
*
*
* This is the value passed to the trustManagers
parameter of the
* {@link SSLContext#init(KeyManager[],TrustManager[],SecureRandom)} method.
*
*
* The default value is null .
*
*
* This method is effectively ignored if {@link #enableSSL()} has not been called or the client connection manager
* has been defined via {@link #httpClientConnectionManager(HttpClientConnectionManager)}.
*
* @param trustManagers The trust managers.
* @return This object (for method chaining).
*/
public RestClientBuilder trustManagers(TrustManager...trustManagers) {
this.trustManagers = trustManagers;
return this;
}
/**
* Trust managers.
*
*
* This is the value passed to the random
parameter of the
* {@link SSLContext#init(KeyManager[],TrustManager[],SecureRandom)} method.
*
*
* The default value is null .
*
*
* This method is effectively ignored if {@link #enableSSL()} has not been called or the client connection manager
* has been defined via {@link #httpClientConnectionManager(HttpClientConnectionManager)}.
*
* @param secureRandom The random number generator.
* @return This object (for method chaining).
*/
public RestClientBuilder secureRandom(SecureRandom secureRandom) {
this.secureRandom = secureRandom;
return this;
}
/**
* Sets the client version by setting the value for the "X-Client-Version" header.
*
* @param version The version string (e.g. "1.2.3" )
* @return This object (for method chaining).
*/
public RestClientBuilder clientVersion(String version) {
return header("X-Client-Version", version);
}
/**
* Adds a {@link RestCallLogger} to the list of interceptors on this class.
*
* @param level The log level to log messages at.
* @param log The logger to log messages to.
* @return This object (for method chaining).
*/
public RestClientBuilder logTo(Level level, Logger log) {
return interceptors(new RestCallLogger(level, log));
}
/**
* When called, the {@link #createConnectionManager()} method will return a {@link PoolingHttpClientConnectionManager}
* instead of a {@link BasicHttpClientConnectionManager}.
*
* @return This object (for method chaining).
*/
public RestClientBuilder pooled() {
this.pooled = true;
return this;
}
/**
* Set up this client to use BASIC auth.
*
* @param host The auth scope hostname.
* @param port The auth scope port.
* @param user The username.
* @param pw The password.
* @return This object (for method chaining).
*/
public RestClientBuilder basicAuth(String host, int port, String user, String pw) {
AuthScope scope = new AuthScope(host, port);
Credentials up = new UsernamePasswordCredentials(user, pw);
CredentialsProvider p = new BasicCredentialsProvider();
p.setCredentials(scope, up);
defaultCredentialsProvider(p);
return this;
}
/**
* Sets the internal {@link HttpClient} to use for handling HTTP communications.
*
* @param httpClient The HTTP client.
* @param keepHttpClientOpen Don't close this client when the {@link RestClient#close()} method is called.
* @return This object (for method chaining).
*/
public RestClientBuilder httpClient(CloseableHttpClient httpClient, boolean keepHttpClientOpen) {
this.httpClient = httpClient;
set(RESTCLIENT_keepHttpClientOpen, keepHttpClientOpen);
return this;
}
/**
* Sets the internal {@link HttpClientConnectionManager}.
*
* @param httpClientConnectionManager The HTTP client connection manager.
* @return This object (for method chaining).
*/
public RestClientBuilder httpClientConnectionManager(HttpClientConnectionManager httpClientConnectionManager) {
this.httpClientConnectionManager = httpClientConnectionManager;
return this;
}
/**
* Sets a mock connection used to construct a connection manager for working against mocked REST interfaces.
*
*
See Also:
*
* - {@doc juneau-rest-client.UnitTesting}
*
*
* @param c The mock connection.
* @return This object (for method chaining).
*/
public RestClientBuilder mockHttpConnection(MockHttpConnection c) {
rootUrl("http://localhost");
return httpClientConnectionManager(new MockHttpClientConnectionManager(c));
}
//-----------------------------------------------------------------------------------------------------------------
// HTTP headers
//-----------------------------------------------------------------------------------------------------------------
/**
* Sets the value for the Accept
request header.
*
*
* This overrides the media type specified on the parser, but is overridden by calling
* header("Accept" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder accept(Object value) {
return header("Accept", value);
}
/**
* Sets the value for the Accept-Charset
request header.
*
*
* This is a shortcut for calling header("Accept-Charset" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder acceptCharset(Object value) {
return header("Accept-Charset", value);
}
/**
* Sets the value for the Accept-Encoding
request header.
*
*
* This is a shortcut for calling header("Accept-Encoding" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder acceptEncoding(Object value) {
return header("Accept-Encoding", value);
}
/**
* Sets the value for the Accept-Language
request header.
*
*
* This is a shortcut for calling header("Accept-Language" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder acceptLanguage(Object value) {
return header("Accept-Language", value);
}
/**
* Sets the value for the Authorization
request header.
*
*
* This is a shortcut for calling header("Authorization" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder authorization(Object value) {
return header("Authorization", value);
}
/**
* Sets the value for the Cache-Control
request header.
*
*
* This is a shortcut for calling header("Cache-Control" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder cacheControl(Object value) {
return header("Cache-Control", value);
}
/**
* Sets the value for the Connection
request header.
*
*
* This is a shortcut for calling header("Connection" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder connection(Object value) {
return header("Connection", value);
}
/**
* Sets the value for the Content-Length
request header.
*
*
* This is a shortcut for calling header("Content-Length" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder contentLength(Object value) {
return header("Content-Length", value);
}
/**
* Sets the value for the Content-Type
request header.
*
*
* This overrides the media type specified on the serializer, but is overridden by calling
* header("Content-Type" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder contentType(Object value) {
return header("Content-Type", value);
}
/**
* Sets the value for the Date
request header.
*
*
* This is a shortcut for calling header("Date" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder date(Object value) {
return header("Date", value);
}
/**
* Sets the value for the Expect
request header.
*
*
* This is a shortcut for calling header("Expect" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder expect(Object value) {
return header("Expect", value);
}
/**
* Sets the value for the Forwarded
request header.
*
*
* This is a shortcut for calling header("Forwarded" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder forwarded(Object value) {
return header("Forwarded", value);
}
/**
* Sets the value for the From
request header.
*
*
* This is a shortcut for calling header("From" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder from(Object value) {
return header("From", value);
}
/**
* Sets the value for the Host
request header.
*
*
* This is a shortcut for calling header("Host" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder host(Object value) {
return header("Host", value);
}
/**
* Sets the value for the If-Match
request header.
*
*
* This is a shortcut for calling header("If-Match" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder ifMatch(Object value) {
return header("If-Match", value);
}
/**
* Sets the value for the If-Modified-Since
request header.
*
*
* This is a shortcut for calling header("If-Modified-Since" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder ifModifiedSince(Object value) {
return header("If-Modified-Since", value);
}
/**
* Sets the value for the If-None-Match
request header.
*
*
* This is a shortcut for calling header("If-None-Match" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder ifNoneMatch(Object value) {
return header("If-None-Match", value);
}
/**
* Sets the value for the If-Range
request header.
*
*
* This is a shortcut for calling header("If-Range" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder ifRange(Object value) {
return header("If-Range", value);
}
/**
* Sets the value for the If-Unmodified-Since
request header.
*
*
* This is a shortcut for calling header("If-Unmodified-Since" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder ifUnmodifiedSince(Object value) {
return header("If-Unmodified-Since", value);
}
/**
* Sets the value for the Max-Forwards
request header.
*
*
* This is a shortcut for calling header("Max-Forwards" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder maxForwards(Object value) {
return header("If-Unmodified-Since", value);
}
/**
* When called, No-Trace: true
is added to requests.
*
*
* This gives the opportunity for the servlet to not log errors on invalid requests.
* This is useful for testing purposes when you don't want your log file to show lots of errors that are simply the
* results of testing.
*
* @return This object (for method chaining).
*/
public RestClientBuilder noTrace() {
return header("No-Trace", true);
}
/**
* Sets the value for the Origin
request header.
*
*
* This is a shortcut for calling header("Origin" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder origin(Object value) {
return header("If-Unmodified-Since", value);
}
/**
* Sets the value for the Pragma
request header.
*
*
* This is a shortcut for calling header("Pragma" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder pragma(Object value) {
return header("Pragma", value);
}
/**
* Sets the value for the Proxy-Authorization
request header.
*
*
* This is a shortcut for calling header("Proxy-Authorization" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder proxyAuthorization(Object value) {
return header("Proxy-Authorization", value);
}
/**
* Sets the value for the Range
request header.
*
*
* This is a shortcut for calling header("Range" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder range(Object value) {
return header("Range", value);
}
/**
* Sets the value for the Referer
request header.
*
*
* This is a shortcut for calling header("Referer" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder referer(Object value) {
return header("Referer", value);
}
/**
* Sets the value for the TE
request header.
*
*
* This is a shortcut for calling header("TE" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder te(Object value) {
return header("TE", value);
}
/**
* Sets the value for the User-Agent
request header.
*
*
* This is a shortcut for calling header("User-Agent" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder userAgent(Object value) {
return header("User-Agent", value);
}
/**
* Sets the value for the Upgrade
request header.
*
*
* This is a shortcut for calling header("Upgrade" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder upgrade(Object value) {
return header("Upgrade", value);
}
/**
* Sets the value for the Via
request header.
*
*
* This is a shortcut for calling header("Via" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder via(Object value) {
return header("Via", value);
}
/**
* Sets the value for the Warning
request header.
*
*
* This is a shortcut for calling header("Warning" , value);
*
* @param value The new header value.
* @return This object (for method chaining).
*/
public RestClientBuilder warning(Object value) {
return header("Warning", value);
}
//-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
/**
* Configuration property: Executor service.
*
*
* Defines the executor service to use when calling future methods on the {@link RestCall} class.
*
*
* This executor service is used to create {@link Future} objects on the following methods:
*
* - {@link RestCall#runFuture()}
*
- {@link RestCall#getResponseFuture(Class)}
*
- {@link RestCall#getResponseFuture(Type,Type...)}
*
- {@link RestCall#getResponseAsString()}
*
*
*
* The default executor service is a single-threaded {@link ThreadPoolExecutor} with a 30 second timeout
* and a queue size of 10.
*
*
See Also:
*
* - {@link RestClient#RESTCLIENT_executorService}
*
- {@link RestClient#RESTCLIENT_executorServiceShutdownOnClose}
*
*
* @param executorService The executor service.
* @param shutdownOnClose Call {@link ExecutorService#shutdown()} when {@link RestClient#close()} is called.
* @return This object (for method chaining).
*/
public RestClientBuilder executorService(ExecutorService executorService, boolean shutdownOnClose) {
set(RESTCLIENT_executorService, executorService);
set(RESTCLIENT_executorServiceShutdownOnClose, shutdownOnClose);
return this;
}
/**
* Configuration property: Request headers.
*
* See Also:
*
* - {@link RestClient#RESTCLIENT_headers}
*
*
* @param key The header name.
* @param value The header value.
* @return This object (for method chaining).
*/
public RestClientBuilder header(String key, Object value) {
return addTo(RESTCLIENT_headers, key, value);
}
/**
* Configuration property: Keep HttpClient open.
*
*
* Don't close this client when the {@link RestClient#close()} method is called.
*
*
See Also:
*
* - {@link RestClient#RESTCLIENT_keepHttpClientOpen}
*
*
* @param value
* The new value for this property.
*
The default value is false .
* @return This object (for method chaining).
*/
public RestClientBuilder keepHttpClientOpen(boolean value) {
return set(RESTCLIENT_keepHttpClientOpen, value);
}
/**
* Configuration property: Call interceptors.
*
*
* Adds an interceptor that gets called immediately after a connection is made.
*
*
See Also:
*
* - {@link RestClient#RESTCLIENT_interceptors}
*
*
* @param value The values to add to this setting.
* @return This object (for method chaining).
*/
public RestClientBuilder interceptors(RestCallInterceptor...value) {
return addTo(RESTCLIENT_interceptors, value);
}
/**
* Configuration property: Parser.
*
*
* The parser to use for parsing POJOs in response bodies.
*
*
See Also:
*
* - {@link RestClient#RESTCLIENT_parser}
*
*
* @param value
* The new value for this setting.
*
The default value is {@link JsonParser#DEFAULT}.
* @return This object (for method chaining).
*/
public RestClientBuilder parser(Class extends Parser> value) {
return set(RESTCLIENT_parser, value);
}
/**
* Configuration property: Parser.
*
*
* Same as {@link #parser(Parser)} except takes in a parser instance.
*
*
See Also:
*
* - {@link RestClient#RESTCLIENT_parser}
*
*
* @param value
* The new value for this setting.
*
The default value is {@link JsonParser#DEFAULT}.
* @return This object (for method chaining).
*/
public RestClientBuilder parser(Parser value) {
return set(RESTCLIENT_parser, value);
}
/**
* Configuration property: Part parser.
*
*
* The parser to use for parsing POJOs from form data, query parameters, headers, and path variables.
*
*
See Also:
*
* - {@link RestClient#RESTCLIENT_partParser}
*
*
* @param value
* The new value for this setting.
*
The default value is {@link OpenApiParser}.
* @return This object (for method chaining).
*/
public RestClientBuilder partParser(Class extends HttpPartParser> value) {
return set(RESTCLIENT_partParser, value);
}
/**
* Configuration property: Part parser.
*
*
* Same as {@link #partParser(Class)} but takes in a parser instance.
*
*
See Also:
*
* - {@link RestClient#RESTCLIENT_partParser}
*
*
* @param value
* The new value for this setting.
*
The default value is {@link OpenApiParser}.
* @return This object (for method chaining).
*/
public RestClientBuilder partParser(HttpPartParser value) {
return set(RESTCLIENT_partParser, value);
}
/**
* Configuration property: Part serializer.
*
*
* The serializer to use for serializing POJOs in form data, query parameters, headers, and path variables.
*
*
See Also:
*
* - {@link RestClient#RESTCLIENT_partSerializer}
*
*
* @param value
* The new value for this setting.
*
The default value is {@link OpenApiSerializer}.
* @return This object (for method chaining).
*/
public RestClientBuilder partSerializer(Class extends HttpPartSerializer> value) {
return set(RESTCLIENT_partSerializer, value);
}
/**
* Configuration property: Part serializer.
*
*
* Same as {@link #partSerializer(Class)} but takes in a parser instance.
*
*
See Also:
*
* - {@link RestClient#RESTCLIENT_partSerializer}
*
*
* @param value
* The new value for this setting.
*
The default value is {@link OpenApiSerializer}.
* @return This object (for method chaining).
*/
public RestClientBuilder partSerializer(HttpPartSerializer value) {
return set(RESTCLIENT_partSerializer, value);
}
/**
* Make HTTP calls retryable if an error response (>=400) is received.
*
* See Also:
*
* - {@link RestClient#RESTCLIENT_retries}
*
- {@link RestClient#RESTCLIENT_retryInterval}
*
- {@link RestClient#RESTCLIENT_retryOn}
*
*
* @param retries The number of retries to attempt.
* @param interval The time in milliseconds between attempts.
* @param retryOn
* Optional object used for determining whether a retry should be attempted.
* If null , uses {@link RetryOn#DEFAULT}.
* @return This object (for method chaining).
*/
public RestClientBuilder retryable(int retries, int interval, RetryOn retryOn) {
set(RESTCLIENT_retries, retries);
set(RESTCLIENT_retryInterval, interval);
set(RESTCLIENT_retryOn, retryOn);
return this;
}
/**
* Configuration property: Root URI.
*
*
* When set, relative URL strings passed in through the various rest call methods (e.g. {@link RestClient#doGet(Object)}
* will be prefixed with the specified root.
*
This root URL is ignored on those methods if you pass in a {@link URL}, {@link URI}, or an absolute URL string.
*
*
See Also:
*
* - {@link RestClient#RESTCLIENT_rootUri}
*
*
* @param value
* The root URL to prefix to relative URL strings.
*
Trailing slashes are trimmed.
*
Usually a String
but you can also pass in URI
and URL
objects as well.
* @return This object (for method chaining).
*/
public RestClientBuilder rootUrl(Object value) {
return set(RESTCLIENT_rootUri, value);
}
/**
* Configuration property: Request query parameters.
*
* See Also:
*
* - {@link RestClient#RESTCLIENT_query}
*
*
* @param key The query parameter name.
* @param value The query parameter value value.
* @return This object (for method chaining).
*/
public RestClientBuilder query(String key, Object value) {
return addTo(RESTCLIENT_query, key, value);
}
/**
* Configuration property: Serializer.
*
*
* The serializer to use for serializing POJOs in request bodies.
*
*
See Also:
*
* - {@link RestClient#RESTCLIENT_serializer}
*
*
* @param value
* The new value for this setting.
*
The default is {@link JsonSerializer}.
* @return This object (for method chaining).
*/
public RestClientBuilder serializer(Class extends Serializer> value) {
return set(RESTCLIENT_serializer, value);
}
/**
* Configuration property: Serializer.
*
*
* Same as {@link #serializer(Class)} but takes in a serializer instance.
*
*
See Also:
*
* - {@link RestClient#RESTCLIENT_serializer}
*
*
* @param value
* The new value for this setting.
*
The default is {@link JsonSerializer}.
* @return This object (for method chaining).
*/
public RestClientBuilder serializer(Serializer value) {
return set(RESTCLIENT_serializer, value);
}
/**
* Configuration property: Add "_type" properties when needed.
*
*
* If true , then "_type" properties will be added to beans if their type cannot be inferred
* through reflection.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_addBeanTypes}
*
*
* @param value
* The new value for this property.
*
The default is false .
* @return This object (for method chaining).
*/
public RestClientBuilder addBeanTypes(boolean value) {
return set(SERIALIZER_addBeanTypes, value);
}
/**
* Configuration property: Add "_type" properties when needed.
*
*
* Shortcut for calling addBeanTypes(true )
.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_addBeanTypes}
*
*
* @return This object (for method chaining).
*/
public RestClientBuilder addBeanTypes() {
return set(SERIALIZER_addBeanTypes, true);
}
/**
* Configuration property: Add type attribute to root nodes.
*
*
* When disabled, it is assumed that the parser knows the exact Java POJO type being parsed, and therefore top-level
* type information that might normally be included to determine the data type will not be serialized.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_addRootType}
*
*
* @param value
* The new value for this property.
*
The default is false .
* @return This object (for method chaining).
*/
public RestClientBuilder addRootType(boolean value) {
return set(SERIALIZER_addRootType, value);
}
/**
* Configuration property: Add type attribute to root nodes.
*
*
* Shortcut for calling addRootType(true )
.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_addRootType}
*
*
* @return This object (for method chaining).
*/
public RestClientBuilder addRootType() {
return set(SERIALIZER_addRootType, true);
}
/**
* Configuration property: Automatically detect POJO recursions.
*
*
* Specifies that recursions should be checked for during serialization.
*
*
Notes:
*
* -
* Checking for recursion can cause a small performance penalty.
*
*
* See Also:
*
* - {@link BeanTraverseContext#BEANTRAVERSE_detectRecursions}
*
*
* @param value
* The new value for this property.
*
The default is false .
* @return This object (for method chaining).
*/
public RestClientBuilder detectRecursions(boolean value) {
return set(BEANTRAVERSE_detectRecursions, value);
}
/**
* Configuration property: Automatically detect POJO recursions.
*
*
* Shortcut for calling detectRecursions(true )
.
*
*
See Also:
*
* - {@link BeanTraverseContext#BEANTRAVERSE_detectRecursions}
*
*
* @return This object (for method chaining).
*/
public RestClientBuilder detectRecursions() {
return set(BEANTRAVERSE_detectRecursions, true);
}
/**
* Configuration property: Ignore recursion errors.
*
*
* If true , when we encounter the same object when serializing a tree, we set the value to null .
* Otherwise, an exception is thrown.
*
*
Notes:
*
* -
* Checking for recursion can cause a small performance penalty.
*
*
* See Also:
*
* - {@link BeanTraverseContext#BEANTRAVERSE_ignoreRecursions}
*
*
* @param value
* The new value for this property.
*
The default is false .
* @return This object (for method chaining).
*/
public RestClientBuilder ignoreRecursions(boolean value) {
return set(BEANTRAVERSE_ignoreRecursions, value);
}
/**
* Configuration property: Ignore recursion errors.
*
*
* Shortcut for calling ignoreRecursions(true )
.
*
*
See Also:
*
* - {@link BeanTraverseContext#BEANTRAVERSE_ignoreRecursions}
*
*
* @return This object (for method chaining).
*/
public RestClientBuilder ignoreRecursions() {
return set(BEANTRAVERSE_ignoreRecursions, true);
}
/**
* Configuration property: Initial depth.
*
*
* The initial indentation level at the root.
*
*
See Also:
*
* - {@link BeanTraverseContext#BEANTRAVERSE_initialDepth}
*
*
* @param value
* The new value for this property.
*
The default is 0
.
* @return This object (for method chaining).
*/
public RestClientBuilder initialDepth(int value) {
return set(BEANTRAVERSE_initialDepth, value);
}
/**
* Configuration property: Serializer listener.
*
*
* Class used to listen for errors and warnings that occur during serialization.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_listener}
*
*
* @param value
* The new value for this property.
* @return This object (for method chaining).
*/
public RestClientBuilder listenerS(Class extends SerializerListener> value) {
return set(SERIALIZER_listener, value);
}
/**
* Configuration property: Max serialization depth.
*
*
* Abort serialization if specified depth is reached in the POJO tree.
*
If this depth is exceeded, an exception is thrown.
*
This prevents stack overflows from occurring when trying to serialize models with recursive references.
*
*
See Also:
*
* - {@link BeanTraverseContext#BEANTRAVERSE_maxDepth}
*
*
* @param value
* The new value for this property.
*
The default is 100
.
* @return This object (for method chaining).
*/
public RestClientBuilder maxDepth(int value) {
return set(BEANTRAVERSE_maxDepth, value);
}
/**
* Configuration property: Sort arrays and collections alphabetically.
*
*
* Copies and sorts the contents of arrays and collections before serializing them.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_sortCollections}
*
*
* @param value
* The new value for this property.
*
The default is false .
* @return This object (for method chaining).
*/
public RestClientBuilder sortCollections(boolean value) {
return set(SERIALIZER_sortCollections, value);
}
/**
* Configuration property: Sort arrays and collections alphabetically.
*
*
* Shortcut for calling sortCollections(true )
.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_sortCollections}
*
*
* @return This object (for method chaining).
*/
public RestClientBuilder sortCollections() {
return set(SERIALIZER_sortCollections, true);
}
/**
* Sets the {@link Serializer#SERIALIZER_sortMaps} property on all serializers in this group.
*
*
* Copies and sorts the contents of maps before serializing them.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_sortMaps}
*
*
* @param value The new value for this property.
* @return This object (for method chaining).
*/
public RestClientBuilder sortMaps(boolean value) {
return set(SERIALIZER_sortMaps, value);
}
/**
* Configuration property: Sort maps alphabetically.
*
*
* Shortcut for calling sortMaps(true )
.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_sortMaps}
*
*
* @return This object (for method chaining).
*/
public RestClientBuilder sortMaps() {
return set(SERIALIZER_sortMaps, true);
}
/**
* Configuration property: Trim empty lists and arrays.
*
*
* If true , empty list values will not be serialized to the output.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_trimEmptyCollections}
*
*
* @param value
* The new value for this property.
*
The default is false .
* @return This object (for method chaining).
*/
public RestClientBuilder trimEmptyCollections(boolean value) {
return set(SERIALIZER_trimEmptyCollections, value);
}
/**
* Configuration property: Trim empty lists and arrays.
*
*
* Shortcut for calling trimEmptyCollections(true )
.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_trimEmptyCollections}
*
*
* @return This object (for method chaining).
*/
public RestClientBuilder trimEmptyCollections() {
return set(SERIALIZER_trimEmptyCollections, true);
}
/**
* Configuration property: Trim empty maps.
*
*
* If true , empty map values will not be serialized to the output.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_trimEmptyMaps}
*
*
* @param value
* The new value for this property.
*
The default is false .
* @return This object (for method chaining).
*/
public RestClientBuilder trimEmptyMaps(boolean value) {
return set(SERIALIZER_trimEmptyMaps, value);
}
/**
* Configuration property: Trim empty maps.
*
*
* Shortcut for calling trimEmptyMaps(true )
.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_trimEmptyMaps}
*
*
* @return This object (for method chaining).
*/
public RestClientBuilder trimEmptyMaps() {
return set(SERIALIZER_trimEmptyMaps, true);
}
/**
* Configuration property: Trim null bean property values.
*
*
* If true , null bean values will not be serialized to the output.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_trimNullProperties}
*
*
* @param value
* The new value for this property.
*
The default is true .
* @return This object (for method chaining).
*/
public RestClientBuilder trimNullProperties(boolean value) {
return set(SERIALIZER_trimNullProperties, value);
}
/**
* Configuration property: Trim strings.
*
*
* If true , string values will be trimmed of whitespace using {@link String#trim()} before being serialized.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_trimStrings}
*
*
* @param value
* The new value for this property.
*
The default is false .
* @return This object (for method chaining).
*/
public RestClientBuilder trimStringsS(boolean value) {
return set(SERIALIZER_trimStrings, value);
}
/**
* Configuration property: Trim strings.
*
*
* Shortcut for calling trimStrings(true )
.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_trimStrings}
*
*
* @return This object (for method chaining).
*/
public RestClientBuilder trimStringsS() {
return set(SERIALIZER_trimStrings, true);
}
/**
* Configuration property: URI context bean.
*
*
* Bean used for resolution of URIs to absolute or root-relative form.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_uriContext}
*
*
* @param value The new value for this property.
* @return This object (for method chaining).
*/
public RestClientBuilder uriContext(UriContext value) {
return set(SERIALIZER_uriContext, value);
}
/**
* Configuration property: URI relativity.
*
*
* Defines what relative URIs are relative to when serializing URI/URL objects.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_uriRelativity}
*
*
* @param value
* The new value for this property.
*
The default is {@link UriRelativity#RESOURCE}
* @return This object (for method chaining).
*/
public RestClientBuilder uriRelativity(UriRelativity value) {
return set(SERIALIZER_uriRelativity, value);
}
/**
* Configuration property: URI resolution.
*
*
* Defines the resolution level for URIs when serializing URI/URL objects.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_uriResolution}
*
*
* @param value
* The new value for this property.
*
The default is {@link UriResolution#NONE}
* @return This object (for method chaining).
*/
public RestClientBuilder uriResolution(UriResolution value) {
return set(SERIALIZER_uriResolution, value);
}
/**
* Configuration property: Maximum indentation.
*
*
* Specifies the maximum indentation level in the serialized document.
*
*
See Also:
*
* - {@link WriterSerializer#WSERIALIZER_maxIndent}
*
*
* @param value
* The new value for this property.
*
The default is 100
.
* @return This object (for method chaining).
*/
public RestClientBuilder maxIndent(int value) {
return set(WSERIALIZER_maxIndent, value);
}
/**
* Configuration property: Quote character.
*
*
* This is the character used for quoting attributes and values.
*
*
See Also:
*
* - {@link WriterSerializer#WSERIALIZER_quoteChar}
*
*
* @param value
* The new value for this property.
*
The default is '"' .
* @return This object (for method chaining).
*/
public RestClientBuilder quoteChar(char value) {
return set(WSERIALIZER_quoteChar, value);
}
/**
* Configuration property: Quote character.
*
*
* Shortcut for calling quoteChar('\'' )
.
*
*
See Also:
*
* - {@link WriterSerializer#WSERIALIZER_quoteChar}
*
*
* @return This object (for method chaining).
*/
public RestClientBuilder sq() {
return set(WSERIALIZER_quoteChar, '\'');
}
/**
* Configuration property: Use whitespace.
*
*
* If true , newlines and indentation and spaces are added to the output to improve readability.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_useWhitespace}
*
*
* @param value
* The new value for this property.
*
The default is false .
* @return This object (for method chaining).
*/
public RestClientBuilder useWhitespace(boolean value) {
return set(SERIALIZER_useWhitespace, value);
}
/**
* Configuration property: Use whitespace.
*
*
* Shortcut for calling useWhitespace(true )
.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_useWhitespace}
*
* @return This object (for method chaining).
*/
public RestClientBuilder useWhitespace() {
return set(SERIALIZER_useWhitespace, true);
}
/**
* Configuration property: Use whitespace.
*
*
* Shortcut for calling useWhitespace(true )
.
*
*
See Also:
*
* - {@link Serializer#SERIALIZER_useWhitespace}
*
*
* @return This object (for method chaining).
*/
public RestClientBuilder ws() {
return set(SERIALIZER_useWhitespace, true);
}
/**
* Configuration property: Binary string format.
*
*
* When using the {@link Serializer#serializeToString(Object)} method on stream-based serializers, this defines the format to use
* when converting the resulting byte array to a string.
*
*
* - {@link OutputStreamSerializer#OSSERIALIZER_binaryFormat}
*
*
* @param value
* The new value for this property.
*
The default is {@link BinaryFormat#HEX}.
* @return This object (for method chaining).
*/
public RestClientBuilder binaryOutputFormat(BinaryFormat value) {
return set(OSSERIALIZER_binaryFormat, value);
}
/**
* Configuration property: Auto-close streams.
*
* If true , InputStreams and Readers passed into parsers will be closed
* after parsing is complete.
*
* See Also:
*
* - {@link Parser#PARSER_autoCloseStreams}
*
*
* @param value
* The new value for this property.
*
The default value is false .
* @return This object (for method chaining).
*/
public RestClientBuilder autoCloseStreams(boolean value) {
return set(PARSER_autoCloseStreams, value);
}
/**
* Configuration property: Auto-close streams.
*
*
* Shortcut for calling autoCloseStreams(true )
.
*
*
See Also:
*
* - {@link Parser#PARSER_autoCloseStreams}
*
*
* @return This object (for method chaining).
*/
public RestClientBuilder autoCloseStreams() {
return set(PARSER_autoCloseStreams, true);
}
/**
* Configuration property: Debug output lines.
*
* When parse errors occur, this specifies the number of lines of input before and after the
* error location to be printed as part of the exception message.
*
* See Also:
*
* - {@link Parser#PARSER_debugOutputLines}
*
*
* @param value
* The new value for this property.
*
The default value is 5
.
* @return This object (for method chaining).
*/
public RestClientBuilder debugOutputLines(int value) {
set(PARSER_debugOutputLines, value);
return this;
}
/**
* Configuration property: Parser listener.
*
*
* Class used to listen for errors and warnings that occur during parsing.
*
*
See Also:
*
* - {@link Parser#PARSER_listener}
*
*
* @param value The new value for this property.
* @return This object (for method chaining).
*/
public RestClientBuilder listenerP(Class extends ParserListener> value) {
return set(PARSER_listener, value);
}
/**
* Configuration property: Strict mode.
*
*
* If true , strict mode for the parser is enabled.
*
*
See Also:
*
* - {@link Parser#PARSER_strict}
*
*
* @param value
* The new value for this property.
*
The default value is false .
* @return This object (for method chaining).
*/
public RestClientBuilder strict(boolean value) {
return set(PARSER_strict, value);
}
/**
* Configuration property: Strict mode.
*
*
* Shortcut for calling strict(true )
.
*
*
See Also:
*
* - {@link Parser#PARSER_strict}
*
*
* @return This object (for method chaining).
*/
public RestClientBuilder strict() {
return set(PARSER_strict, true);
}
/**
* Configuration property: Trim parsed strings.
*
*
* If true , string values will be trimmed of whitespace using {@link String#trim()} before being added to
* the POJO.
*
*
See Also:
*
* - {@link Parser#PARSER_trimStrings}
*
*
* @param value
* The new value for this property.
*
The default value is false .
* @return This object (for method chaining).
*/
public RestClientBuilder trimStringsP(boolean value) {
return set(PARSER_trimStrings, value);
}
/**
* Configuration property: Trim parsed strings.
*
*
* Shortcut for calling trimStrings(true )
.
*
*
See Also:
*
* - {@link Parser#PARSER_trimStrings}
*
*
* @return This object (for method chaining).
*/
public RestClientBuilder trimStringsP() {
return set(PARSER_trimStrings, true);
}
/**
* Configuration property: Unbuffered.
*
* If true , don't use internal buffering during parsing.
*
* See Also:
*
* - {@link Parser#PARSER_unbuffered}
*
*
* @param value
* The new value for this property.
*
The default value is false .
* @return This object (for method chaining).
*/
public RestClientBuilder unbuffered(boolean value) {
return set(PARSER_unbuffered, value);
}
/**
* Configuration property: Unbuffered.
*
*
* Shortcut for calling unbuffered(true )
.
*
*
See Also:
*
* - {@link Parser#PARSER_unbuffered}
*
*
* @return This object (for method chaining).
*/
public RestClientBuilder unbuffered() {
return set(PARSER_unbuffered, true);
}
/**
* Configuration property: File charset.
*
*
* The character set to use for reading Files
from the file system.
*
*
See Also:
*
* - {@link ReaderParser#RPARSER_fileCharset}
*
*
* @param value
* The new value for this property.
*
The default value is "DEFAULT" which causes the system default to be used.
* @return This object (for method chaining).
*/
public RestClientBuilder fileCharset(String value) {
return set(RPARSER_fileCharset, value);
}
/**
* Configuration property: Input stream charset.
*
*
* The character set to use for converting InputStreams
and byte arrays to readers.
*
*
See Also:
*
* - {@link ReaderParser#RPARSER_inputStreamCharset}
*
*
* @param value
* The new value for this property.
*
The default value is "UTF-8" .
* @return This object (for method chaining).
*/
public RestClientBuilder inputStreamCharset(String value) {
return set(RPARSER_inputStreamCharset, value);
}
/**
* Configuration property: Binary input format.
*
*
* When using the {@link Parser#parse(Object,Class)} method on stream-based parsers and the input is a string, this defines the format to use
* when converting the string into a byte array.
*
*
See Also:
*
* - {@link InputStreamParser#ISPARSER_binaryFormat}
*
*
* @param value
* The new value for this property.
*
The default value is {@link BinaryFormat#HEX}.
* @return This object (for method chaining).
*/
public RestClientBuilder binaryInputFormat(BinaryFormat value) {
return set(ISPARSER_binaryFormat, value);
}
/**
* Configuration property: Parameter format.
*
* See Also:
*
* - {@link UonSerializer#UON_paramFormat}
*
*
* @param value The new value for this property.
* @return This object (for method chaining).
*/
public RestClientBuilder paramFormat(String value) {
return set(UON_paramFormat, value);
}
/**
* Configuration property: Parameter format.
*
* See Also:
*
* - {@link UonSerializer#UON_paramFormat}
*
*
* @return This object (for method chaining).
*/
public RestClientBuilder paramFormatPlain() {
return set(UON_paramFormat, "PLAINTEXT");
}
@Override /* BeanContextBuilder */
public RestClientBuilder beanClassVisibility(Visibility value) {
super.beanClassVisibility(value);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder beanConstructorVisibility(Visibility value) {
super.beanConstructorVisibility(value);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder beanDictionary(boolean append, Object...values) {
super.beanDictionary(append, values);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder beanDictionary(Class>...values) {
super.beanDictionary(values);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder beanDictionary(Object...values) {
super.beanDictionary(values);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder beanDictionaryRemove(Object...values) {
super.beanDictionaryRemove(values);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder beanFieldVisibility(Visibility value) {
super.beanFieldVisibility(value);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder beanFilters(boolean append, Object...values) {
super.beanFilters(append, values);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder beanFilters(Class>...values) {
super.beanFilters(values);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder beanFilters(Object...values) {
super.beanFilters(values);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder beanFiltersRemove(Object...values) {
super.beanFiltersRemove(values);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder beanMapPutReturnsOldValue(boolean value) {
super.beanMapPutReturnsOldValue(value);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder beanMapPutReturnsOldValue() {
super.beanMapPutReturnsOldValue();
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder beanMethodVisibility(Visibility value) {
super.beanMethodVisibility(value);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder beansRequireDefaultConstructor(boolean value) {
super.beansRequireDefaultConstructor(value);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder beansRequireDefaultConstructor() {
super.beansRequireDefaultConstructor();
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder beansRequireSerializable(boolean value) {
super.beansRequireSerializable(value);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder beansRequireSerializable() {
super.beansRequireSerializable();
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder beansRequireSettersForGetters(boolean value) {
super.beansRequireSettersForGetters(value);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder beansRequireSettersForGetters() {
super.beansRequireSettersForGetters();
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder beansRequireSomeProperties(boolean value) {
super.beansRequireSomeProperties(value);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder beanTypePropertyName(String value) {
super.beanTypePropertyName(value);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder debug() {
super.debug();
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder example(Class c, T o) {
super.example(c, o);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder ignoreInvocationExceptionsOnGetters(boolean value) {
super.ignoreInvocationExceptionsOnGetters(value);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder ignoreInvocationExceptionsOnGetters() {
super.ignoreInvocationExceptionsOnGetters();
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder ignoreInvocationExceptionsOnSetters(boolean value) {
super.ignoreInvocationExceptionsOnSetters(value);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder ignoreInvocationExceptionsOnSetters() {
super.ignoreInvocationExceptionsOnSetters();
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder ignorePropertiesWithoutSetters(boolean value) {
super.ignorePropertiesWithoutSetters(value);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder ignoreUnknownBeanProperties(boolean value) {
super.ignoreUnknownBeanProperties(value);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder ignoreUnknownBeanProperties() {
super.ignoreUnknownBeanProperties();
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder ignoreUnknownNullBeanProperties(boolean value) {
super.ignoreUnknownNullBeanProperties(value);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder implClass(Class interfaceClass, Class extends T> implClass) {
super.implClass(interfaceClass, implClass);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder implClasses(Map> values) {
super.implClasses(values);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder locale(Locale value) {
super.locale(value);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder mediaType(MediaType value) {
super.mediaType(value);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder notBeanClasses(boolean append, Object...values) {
super.notBeanClasses(append, values);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder notBeanClasses(Class>...values) {
super.notBeanClasses(values);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder notBeanClasses(Object...values) {
super.notBeanClasses(values);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder notBeanClassesRemove(Object...values) {
super.notBeanClassesRemove(values);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder notBeanPackages(boolean append, Object...values) {
super.notBeanPackages(append, values);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder notBeanPackages(Object...values) {
super.notBeanPackages(values);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder notBeanPackages(String...values) {
super.notBeanPackages(values);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder notBeanPackagesRemove(Object...values) {
super.notBeanPackagesRemove(values);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder pojoSwaps(boolean append, Object...values) {
super.pojoSwaps(append, values);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder pojoSwaps(Class>...values) {
super.pojoSwaps(values);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder pojoSwaps(Object...values) {
super.pojoSwaps(values);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder pojoSwapsRemove(Object...values) {
super.pojoSwapsRemove(values);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder sortProperties(boolean value) {
super.sortProperties(value);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder sortProperties() {
super.sortProperties();
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder timeZone(TimeZone value) {
super.timeZone(value);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder useEnumNames() {
super.useEnumNames();
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder useInterfaceProxies(boolean value) {
super.useInterfaceProxies(value);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder useJavaBeanIntrospector(boolean value) {
super.useJavaBeanIntrospector(value);
return this;
}
@Override /* BeanContextBuilder */
public RestClientBuilder useJavaBeanIntrospector() {
super.useJavaBeanIntrospector();
return this;
}
@Override /* ContextBuilder */
public RestClientBuilder set(String name, Object value) {
super.set(name, value);
return this;
}
@Override /* ContextBuilder */
public RestClientBuilder set(boolean append, String name, Object value) {
super.set(append, name, value);
return this;
}
@Override /* ContextBuilder */
public RestClientBuilder set(Map properties) {
super.set(properties);
return this;
}
@Override /* ContextBuilder */
public RestClientBuilder add(Map properties) {
super.add(properties);
return this;
}
@Override /* ContextBuilder */
public RestClientBuilder addTo(String name, Object value) {
super.addTo(name, value);
return this;
}
@Override /* ContextBuilder */
public RestClientBuilder addTo(String name, String key, Object value) {
super.addTo(name, key, value);
return this;
}
@Override /* ContextBuilder */
public RestClientBuilder removeFrom(String name, Object value) {
super.removeFrom(name, value);
return this;
}
@Override /* ContextBuilder */
public RestClientBuilder apply(PropertyStore copyFrom) {
super.apply(copyFrom);
return this;
}
//------------------------------------------------------------------------------------------------
// Passthrough methods for HttpClientBuilder.
//------------------------------------------------------------------------------------------------
/**
* @param redirectStrategy
* @return This object (for method chaining).
* @see HttpClientBuilder#setRedirectStrategy(RedirectStrategy)
*/
public RestClientBuilder redirectStrategy(RedirectStrategy redirectStrategy) {
httpClientBuilder.setRedirectStrategy(redirectStrategy);
return this;
}
/**
* @param cookieSpecRegistry
* @return This object (for method chaining).
* @see HttpClientBuilder#setDefaultCookieSpecRegistry(Lookup)
*/
public RestClientBuilder defaultCookieSpecRegistry(Lookup cookieSpecRegistry) {
httpClientBuilder.setDefaultCookieSpecRegistry(cookieSpecRegistry);
return this;
}
/**
* @param requestExec
* @return This object (for method chaining).
* @see HttpClientBuilder#setRequestExecutor(HttpRequestExecutor)
*/
public RestClientBuilder requestExecutor(HttpRequestExecutor requestExec) {
httpClientBuilder.setRequestExecutor(requestExec);
return this;
}
/**
* @param hostnameVerifier
* @return This object (for method chaining).
* @see HttpClientBuilder#setSSLHostnameVerifier(HostnameVerifier)
*/
public RestClientBuilder sslHostnameVerifier(HostnameVerifier hostnameVerifier) {
httpClientBuilder.setSSLHostnameVerifier(hostnameVerifier);
return this;
}
/**
* @param publicSuffixMatcher
* @return This object (for method chaining).
* @see HttpClientBuilder#setPublicSuffixMatcher(PublicSuffixMatcher)
*/
public RestClientBuilder publicSuffixMatcher(PublicSuffixMatcher publicSuffixMatcher) {
httpClientBuilder.setPublicSuffixMatcher(publicSuffixMatcher);
return this;
}
/**
* @param sslContext
* @return This object (for method chaining).
* @see HttpClientBuilder#setSSLContext(SSLContext)
*/
public RestClientBuilder sslContext(SSLContext sslContext) {
httpClientBuilder.setSSLContext(sslContext);
return this;
}
/**
* @param sslSocketFactory
* @return This object (for method chaining).
* @see HttpClientBuilder#setSSLSocketFactory(LayeredConnectionSocketFactory)
*/
public RestClientBuilder sslSocketFactory(LayeredConnectionSocketFactory sslSocketFactory) {
httpClientBuilder.setSSLSocketFactory(sslSocketFactory);
return this;
}
/**
* @param maxConnTotal
* @return This object (for method chaining).
* @see HttpClientBuilder#setMaxConnTotal(int)
*/
public RestClientBuilder maxConnTotal(int maxConnTotal) {
httpClientBuilder.setMaxConnTotal(maxConnTotal);
return this;
}
/**
* @param maxConnPerRoute
* @return This object (for method chaining).
* @see HttpClientBuilder#setMaxConnPerRoute(int)
*/
public RestClientBuilder maxConnPerRoute(int maxConnPerRoute) {
httpClientBuilder.setMaxConnPerRoute(maxConnPerRoute);
return this;
}
/**
* @param config
* @return This object (for method chaining).
* @see HttpClientBuilder#setDefaultSocketConfig(SocketConfig)
*/
public RestClientBuilder defaultSocketConfig(SocketConfig config) {
httpClientBuilder.setDefaultSocketConfig(config);
return this;
}
/**
* @param config
* @return This object (for method chaining).
* @see HttpClientBuilder#setDefaultConnectionConfig(ConnectionConfig)
*/
public RestClientBuilder defaultConnectionConfig(ConnectionConfig config) {
httpClientBuilder.setDefaultConnectionConfig(config);
return this;
}
/**
* @param connTimeToLive
* @param connTimeToLiveTimeUnit
* @return This object (for method chaining).
* @see HttpClientBuilder#setConnectionTimeToLive(long,TimeUnit)
*/
public RestClientBuilder connectionTimeToLive(long connTimeToLive, TimeUnit connTimeToLiveTimeUnit) {
httpClientBuilder.setConnectionTimeToLive(connTimeToLive, connTimeToLiveTimeUnit);
return this;
}
/**
* @param connManager
* @return This object (for method chaining).
* @see HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)
*/
public RestClientBuilder connectionManager(HttpClientConnectionManager connManager) {
this.httpClientConnectionManager = connManager;
httpClientBuilder.setConnectionManager(connManager);
return this;
}
/**
* @param shared
* @return This object (for method chaining).
* @see HttpClientBuilder#setConnectionManagerShared(boolean)
*/
public RestClientBuilder connectionManagerShared(boolean shared) {
httpClientBuilder.setConnectionManagerShared(shared);
return this;
}
/**
* @param reuseStrategy
* @return This object (for method chaining).
* @see HttpClientBuilder#setConnectionReuseStrategy(ConnectionReuseStrategy)
*/
public RestClientBuilder connectionReuseStrategy(ConnectionReuseStrategy reuseStrategy) {
httpClientBuilder.setConnectionReuseStrategy(reuseStrategy);
return this;
}
/**
* @param keepAliveStrategy
* @return This object (for method chaining).
* @see HttpClientBuilder#setKeepAliveStrategy(ConnectionKeepAliveStrategy)
*/
public RestClientBuilder keepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy) {
httpClientBuilder.setKeepAliveStrategy(keepAliveStrategy);
return this;
}
/**
* @param targetAuthStrategy
* @return This object (for method chaining).
* @see HttpClientBuilder#setTargetAuthenticationStrategy(AuthenticationStrategy)
*/
public RestClientBuilder targetAuthenticationStrategy(AuthenticationStrategy targetAuthStrategy) {
httpClientBuilder.setTargetAuthenticationStrategy(targetAuthStrategy);
return this;
}
/**
* @param proxyAuthStrategy
* @return This object (for method chaining).
* @see HttpClientBuilder#setProxyAuthenticationStrategy(AuthenticationStrategy)
*/
public RestClientBuilder proxyAuthenticationStrategy(AuthenticationStrategy proxyAuthStrategy) {
httpClientBuilder.setProxyAuthenticationStrategy(proxyAuthStrategy);
return this;
}
/**
* @param userTokenHandler
* @return This object (for method chaining).
* @see HttpClientBuilder#setUserTokenHandler(UserTokenHandler)
*/
public RestClientBuilder userTokenHandler(UserTokenHandler userTokenHandler) {
httpClientBuilder.setUserTokenHandler(userTokenHandler);
return this;
}
/**
* @return This object (for method chaining).
* @see HttpClientBuilder#disableConnectionState()
*/
public RestClientBuilder disableConnectionState() {
httpClientBuilder.disableConnectionState();
return this;
}
/**
* @param schemePortResolver
* @return This object (for method chaining).
* @see HttpClientBuilder#setSchemePortResolver(SchemePortResolver)
*/
public RestClientBuilder schemePortResolver(SchemePortResolver schemePortResolver) {
httpClientBuilder.setSchemePortResolver(schemePortResolver);
return this;
}
/**
* @param userAgent
* @return This object (for method chaining).
* @see HttpClientBuilder#setUserAgent(String)
*/
public RestClientBuilder userAgent(String userAgent) {
httpClientBuilder.setUserAgent(userAgent);
return this;
}
/**
* @param defaultHeaders
* @return This object (for method chaining).
* @see HttpClientBuilder#setDefaultHeaders(Collection)
*/
public RestClientBuilder defaultHeaders(Collection extends Header> defaultHeaders) {
httpClientBuilder.setDefaultHeaders(defaultHeaders);
return this;
}
/**
* @param itcp
* @return This object (for method chaining).
* @see HttpClientBuilder#addInterceptorFirst(HttpResponseInterceptor)
*/
public RestClientBuilder addInterceptorFirst(HttpResponseInterceptor itcp) {
httpClientBuilder.addInterceptorFirst(itcp);
return this;
}
/**
* @param itcp
* @return This object (for method chaining).
* @see HttpClientBuilder#addInterceptorLast(HttpResponseInterceptor)
*/
public RestClientBuilder addInterceptorLast(HttpResponseInterceptor itcp) {
httpClientBuilder.addInterceptorLast(itcp);
return this;
}
/**
* @param itcp
* @return This object (for method chaining).
* @see HttpClientBuilder#addInterceptorFirst(HttpRequestInterceptor)
*/
public RestClientBuilder addInterceptorFirst(HttpRequestInterceptor itcp) {
httpClientBuilder.addInterceptorFirst(itcp);
return this;
}
/**
* @param itcp
* @return This object (for method chaining).
* @see HttpClientBuilder#addInterceptorLast(HttpRequestInterceptor)
*/
public RestClientBuilder addInterceptorLast(HttpRequestInterceptor itcp) {
httpClientBuilder.addInterceptorLast(itcp);
return this;
}
/**
* @return This object (for method chaining).
* @see HttpClientBuilder#disableCookieManagement()
*/
public RestClientBuilder disableCookieManagement() {
httpClientBuilder.disableCookieManagement();
return this;
}
/**
* @return This object (for method chaining).
* @see HttpClientBuilder#disableContentCompression()
*/
public RestClientBuilder disableContentCompression() {
httpClientBuilder.disableContentCompression();
return this;
}
/**
* @return This object (for method chaining).
* @see HttpClientBuilder#disableAuthCaching()
*/
public RestClientBuilder disableAuthCaching() {
httpClientBuilder.disableAuthCaching();
return this;
}
/**
* @param httpprocessor
* @return This object (for method chaining).
* @see HttpClientBuilder#setHttpProcessor(HttpProcessor)
*/
public RestClientBuilder httpProcessor(HttpProcessor httpprocessor) {
httpClientBuilder.setHttpProcessor(httpprocessor);
return this;
}
/**
* @param retryHandler
* @return This object (for method chaining).
* @see HttpClientBuilder#setRetryHandler(HttpRequestRetryHandler)
*/
public RestClientBuilder retryHandler(HttpRequestRetryHandler retryHandler) {
httpClientBuilder.setRetryHandler(retryHandler);
return this;
}
/**
* @return This object (for method chaining).
* @see HttpClientBuilder#disableAutomaticRetries()
*/
public RestClientBuilder disableAutomaticRetries() {
httpClientBuilder.disableAutomaticRetries();
return this;
}
/**
* @param proxy
* @return This object (for method chaining).
* @see HttpClientBuilder#setProxy(HttpHost)
*/
public RestClientBuilder proxy(HttpHost proxy) {
httpClientBuilder.setProxy(proxy);
return this;
}
/**
* @param routePlanner
* @return This object (for method chaining).
* @see HttpClientBuilder#setRoutePlanner(HttpRoutePlanner)
*/
public RestClientBuilder routePlanner(HttpRoutePlanner routePlanner) {
httpClientBuilder.setRoutePlanner(routePlanner);
return this;
}
/**
* @return This object (for method chaining).
* @see HttpClientBuilder#disableRedirectHandling()
*/
public RestClientBuilder disableRedirectHandling() {
httpClientBuilder.disableRedirectHandling();
return this;
}
/**
* @param connectionBackoffStrategy
* @return This object (for method chaining).
* @see HttpClientBuilder#setConnectionBackoffStrategy(ConnectionBackoffStrategy)
*/
public RestClientBuilder connectionBackoffStrategy(ConnectionBackoffStrategy connectionBackoffStrategy) {
httpClientBuilder.setConnectionBackoffStrategy(connectionBackoffStrategy);
return this;
}
/**
* @param backoffManager
* @return This object (for method chaining).
* @see HttpClientBuilder#setBackoffManager(BackoffManager)
*/
public RestClientBuilder backoffManager(BackoffManager backoffManager) {
httpClientBuilder.setBackoffManager(backoffManager);
return this;
}
/**
* @param serviceUnavailStrategy
* @return This object (for method chaining).
* @see HttpClientBuilder#setServiceUnavailableRetryStrategy(ServiceUnavailableRetryStrategy)
*/
public RestClientBuilder serviceUnavailableRetryStrategy(ServiceUnavailableRetryStrategy serviceUnavailStrategy) {
httpClientBuilder.setServiceUnavailableRetryStrategy(serviceUnavailStrategy);
return this;
}
/**
* @param cookieStore
* @return This object (for method chaining).
* @see HttpClientBuilder#setDefaultCookieStore(CookieStore)
*/
public RestClientBuilder defaultCookieStore(CookieStore cookieStore) {
httpClientBuilder.setDefaultCookieStore(cookieStore);
return this;
}
/**
* @param credentialsProvider
* @return This object (for method chaining).
* @see HttpClientBuilder#setDefaultCredentialsProvider(CredentialsProvider)
*/
public RestClientBuilder defaultCredentialsProvider(CredentialsProvider credentialsProvider) {
httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
return this;
}
/**
* @param authSchemeRegistry
* @return This object (for method chaining).
* @see HttpClientBuilder#setDefaultAuthSchemeRegistry(Lookup)
*/
public RestClientBuilder defaultAuthSchemeRegistry(Lookup authSchemeRegistry) {
httpClientBuilder.setDefaultAuthSchemeRegistry(authSchemeRegistry);
return this;
}
/**
* @param contentDecoderMap
* @return This object (for method chaining).
* @see HttpClientBuilder#setContentDecoderRegistry(Map)
*/
public RestClientBuilder contentDecoderRegistry(Map contentDecoderMap) {
httpClientBuilder.setContentDecoderRegistry(contentDecoderMap);
return this;
}
/**
* @param config
* @return This object (for method chaining).
* @see HttpClientBuilder#setDefaultRequestConfig(RequestConfig)
*/
public RestClientBuilder defaultRequestConfig(RequestConfig config) {
httpClientBuilder.setDefaultRequestConfig(config);
return this;
}
/**
* @return This object (for method chaining).
* @see HttpClientBuilder#useSystemProperties()
*/
public RestClientBuilder useSystemProperties() {
httpClientBuilder.useSystemProperties();
return this;
}
/**
* @return This object (for method chaining).
* @see HttpClientBuilder#evictExpiredConnections()
*/
public RestClientBuilder evictExpiredConnections() {
httpClientBuilder.evictExpiredConnections();
return this;
}
/**
* @param maxIdleTime
* @param maxIdleTimeUnit
* @return This object (for method chaining).
* @see HttpClientBuilder#evictIdleConnections(long,TimeUnit)
*/
public RestClientBuilder evictIdleConnections(long maxIdleTime, TimeUnit maxIdleTimeUnit) {
httpClientBuilder.evictIdleConnections(maxIdleTime, maxIdleTimeUnit);
return this;
}
private static String[] getDefaultProtocols() {
String sp = System.getProperty("transport.client.protocol");
if (isEmpty(sp))
return new String[] {"SSL_TLS","TLS","SSL"};
return StringUtils.split(sp, ',');
}
}