001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.rest.client;
014
015import static org.apache.juneau.internal.StringUtils.*;
016import static org.apache.juneau.parser.Parser.*;
017import static org.apache.juneau.rest.client.RestClient.*;
018import static org.apache.juneau.serializer.Serializer.*;
019import static org.apache.juneau.uon.UonSerializer.*;
020
021import java.lang.reflect.*;
022import java.net.*;
023import java.security.*;
024import java.util.*;
025import java.util.concurrent.*;
026import java.util.logging.*;
027
028import javax.net.ssl.*;
029
030import org.apache.http.*;
031import org.apache.http.auth.*;
032import org.apache.http.client.*;
033import org.apache.http.client.CookieStore;
034import org.apache.http.client.config.*;
035import org.apache.http.client.entity.*;
036import org.apache.http.config.*;
037import org.apache.http.conn.*;
038import org.apache.http.conn.routing.*;
039import org.apache.http.conn.socket.*;
040import org.apache.http.conn.ssl.*;
041import org.apache.http.conn.util.*;
042import org.apache.http.cookie.*;
043import org.apache.http.impl.client.*;
044import org.apache.http.impl.conn.*;
045import org.apache.http.protocol.*;
046import org.apache.juneau.*;
047import org.apache.juneau.http.*;
048import org.apache.juneau.httppart.*;
049import org.apache.juneau.json.*;
050import org.apache.juneau.parser.*;
051import org.apache.juneau.serializer.*;
052import org.apache.juneau.uon.*;
053
054/**
055 * Builder class for the {@link RestClient} class.
056 * 
057 * <p>
058 * Instances of this class are created by the following methods:
059 * <ul>
060 *    <li>{@link RestClient#create()} - Create from scratch.
061 *    <li>{@link RestClient#create(Serializer,Parser)} - Create from scratch using specified serializer/parser.
062 *    <li>{@link RestClient#create(Class,Class)} - Create from scratch using specified serializer/parser classes.
063 *    <li>{@link RestClient#builder()} - Copy settings from an existing client.
064 * </ul>
065 * 
066 * <h5 class='section'>See Also:</h5>
067 * <ul>
068 *    <li class='link'><a class="doclink" href="../../../../../overview-summary.html#juneau-rest-client">Overview &gt; juneau-rest-client</a>
069 * </ul>
070 */
071public class RestClientBuilder extends BeanContextBuilder {
072
073   private HttpClientConnectionManager httpClientConnectionManager;
074   private HttpClientBuilder httpClientBuilder;
075   private CloseableHttpClient httpClient;
076   private SSLOpts sslOpts;
077   private boolean pooled;
078
079   /**
080    * Constructor.
081    */
082   RestClientBuilder(PropertyStore ps, HttpClientBuilder httpClientBuilder) {
083      super(ps);
084      this.httpClientBuilder = httpClientBuilder != null ? httpClientBuilder : createHttpClientBuilder();
085   }
086
087   @SuppressWarnings("resource")
088   @Override /* ContextBuilder */
089   public RestClient build() {
090      try {
091         CloseableHttpClient c = httpClient != null ? httpClient : createHttpClient();
092         PropertyStore ps = psb.build();
093
094         return new RestClient(ps, httpClientBuilder, c);
095      } catch (Exception e) {
096         throw new RuntimeException(e);
097      }
098   }
099
100   /**
101    * Creates an instance of an {@link HttpClient} to be used to handle all HTTP communications with the target server.
102    * 
103    * <p>
104    * This HTTP client is used when the HTTP client is not specified through one of the constructors or the
105    * {@link #httpClient(CloseableHttpClient, boolean)} method.
106    * 
107    * <p>
108    * Subclasses can override this method to provide specially-configured HTTP clients to handle stuff such as
109    * SSL/TLS certificate handling, authentication, etc.
110    * 
111    * <p>
112    * The default implementation returns an instance of {@link HttpClient} using the client builder returned by
113    * {@link #createHttpClientBuilder()}.
114    * 
115    * @return The HTTP client to use.
116    * @throws Exception
117    */
118   protected CloseableHttpClient createHttpClient() throws Exception {
119      // Don't call createConnectionManager() if RestClient.setConnectionManager() was called.
120      if (httpClientConnectionManager == null)
121         httpClientBuilder.setConnectionManager(createConnectionManager());
122      return httpClientBuilder.build();
123   }
124
125   /**
126    * Creates an instance of an {@link HttpClientBuilder} to be used to create the {@link HttpClient}.
127    * 
128    * <p>
129    * Subclasses can override this method to provide their own client builder.
130    * 
131    * <p>
132    * The predefined method returns an {@link HttpClientBuilder} with the following settings:
133    * <ul>
134    *    <li>Lax redirect strategy.
135    *    <li>The connection manager returned by {@link #createConnectionManager()}.
136    * </ul>
137    * 
138    * @return The HTTP client builder to use to create the HTTP client.
139    */
140   protected HttpClientBuilder createHttpClientBuilder() {
141      HttpClientBuilder b = HttpClientBuilder.create();
142      b.setRedirectStrategy(new AllowAllRedirects());
143      return b;
144   }
145
146   /**
147    * Creates the {@link HttpClientConnectionManager} returned by {@link #createConnectionManager()}.
148    * 
149    * <p>
150    * Subclasses can override this method to provide their own connection manager.
151    * 
152    * <p>
153    * The default implementation returns an instance of a {@link PoolingHttpClientConnectionManager}.
154    * 
155    * @return The HTTP client builder to use to create the HTTP client.
156    */
157   @SuppressWarnings("resource")
158   protected HttpClientConnectionManager createConnectionManager() {
159      if (sslOpts != null) {
160         HostnameVerifier hv = null;
161         switch (sslOpts.getHostVerify()) {
162            case LAX: hv = new NoopHostnameVerifier(); break;
163            case DEFAULT: hv = new DefaultHostnameVerifier(); break;
164            default: throw new RuntimeException("Programmer error");
165         }
166
167         for (String p : split(sslOpts.getProtocols())) {
168            try {
169               TrustManager tm = new SimpleX509TrustManager(sslOpts.getCertValidate() == SSLOpts.CertValidate.LAX);
170
171               SSLContext ctx = SSLContext.getInstance(p);
172               ctx.init(null, new TrustManager[] { tm }, null);
173
174               // Create a socket to ensure this algorithm is acceptable.
175               // This will correctly disallow certain configurations (such as SSL_TLS under FIPS)
176               ctx.getSocketFactory().createSocket().close();
177               SSLConnectionSocketFactory sf = new SSLConnectionSocketFactory(ctx, hv);
178               setSSLSocketFactory(sf);
179
180               Registry<ConnectionSocketFactory> r = RegistryBuilder.<ConnectionSocketFactory> create().register("https", sf).build();
181
182               return (pooled ? new PoolingHttpClientConnectionManager(r) : new BasicHttpClientConnectionManager(r));
183            } catch (Throwable t) {}
184         }
185      }
186
187         // Using pooling connection so that this client is threadsafe.
188      return (pooled ? new PoolingHttpClientConnectionManager() : new BasicHttpClientConnectionManager());
189   }
190
191   /**
192    * Enable SSL support on this client.
193    * 
194    * @param opts
195    *    The SSL configuration options.
196    *    See {@link SSLOpts} for details.
197    *    This method is a no-op if <code>sslConfig</code> is <jk>null</jk>.
198    * @return This object (for method chaining).
199    * @throws KeyStoreException
200    * @throws NoSuchAlgorithmException
201    */
202   public RestClientBuilder enableSSL(SSLOpts opts) throws KeyStoreException, NoSuchAlgorithmException {
203      this.sslOpts = opts;
204      return this;
205   }
206
207   /**
208    * Enable LAX SSL support.
209    * 
210    * <p>
211    * Certificate chain validation and hostname verification is disabled.
212    * 
213    * @return This object (for method chaining).
214    * @throws KeyStoreException
215    * @throws NoSuchAlgorithmException
216    */
217   public RestClientBuilder enableLaxSSL() throws KeyStoreException, NoSuchAlgorithmException {
218      return enableSSL(SSLOpts.LAX);
219   }
220
221   /**
222    * Sets the client version by setting the value for the <js>"X-Client-Version"</js> header.
223    * 
224    * @param version The version string (e.g. <js>"1.2.3"</js>)
225    * @return This object (for method chaining).
226    */
227   public RestClientBuilder clientVersion(String version) {
228      return header("X-Client-Version", version);
229   }
230
231   /**
232    * Adds a {@link RestCallLogger} to the list of interceptors on this class.
233    * 
234    * @param level The log level to log messages at.
235    * @param log The logger to log messages to.
236    * @return This object (for method chaining).
237    */
238   public RestClientBuilder logTo(Level level, Logger log) {
239      return interceptors(new RestCallLogger(level, log));
240   }
241
242   /**
243    * When called, the {@link #createConnectionManager()} method will return a {@link PoolingHttpClientConnectionManager}
244    * instead of a {@link BasicHttpClientConnectionManager}.
245    * 
246    * @return This object (for method chaining).
247    */
248   public RestClientBuilder pooled() {
249      this.pooled = true;
250      return this;
251   }
252
253   /**
254    * Set up this client to use BASIC auth.
255    * 
256    * @param host The auth scope hostname.
257    * @param port The auth scope port.
258    * @param user The username.
259    * @param pw The password.
260    * @return This object (for method chaining).
261    */
262   public RestClientBuilder basicAuth(String host, int port, String user, String pw) {
263      AuthScope scope = new AuthScope(host, port);
264      Credentials up = new UsernamePasswordCredentials(user, pw);
265      CredentialsProvider p = new BasicCredentialsProvider();
266      p.setCredentials(scope, up);
267      setDefaultCredentialsProvider(p);
268      return this;
269   }
270
271   /**
272    * Sets the internal {@link HttpClient} to use for handling HTTP communications.
273    * 
274    * @param httpClient The HTTP client.
275    * @param keepHttpClientOpen Don't close this client when the {@link RestClient#close()} method is called.
276    * @return This object (for method chaining).
277    */
278   public RestClientBuilder httpClient(CloseableHttpClient httpClient, boolean keepHttpClientOpen) {
279      this.httpClient = httpClient;
280      set(RESTCLIENT_keepHttpClientOpen, keepHttpClientOpen);
281      return this;
282   }
283
284
285   //--------------------------------------------------------------------------------
286   // HTTP headers
287   //--------------------------------------------------------------------------------
288
289   /**
290    * Sets the value for the <code>Accept</code> request header.
291    * 
292    * <p>
293    * This overrides the media type specified on the parser, but is overridden by calling
294    * <code>header(<js>"Accept"</js>, value);</code>
295    * 
296    * @param value The new header value.
297    * @return This object (for method chaining).
298    */
299   public RestClientBuilder accept(Object value) {
300      return header("Accept", value);
301   }
302
303   /**
304    * Sets the value for the <code>Accept-Charset</code> request header.
305    * 
306    * <p>
307    * This is a shortcut for calling <code>header(<js>"Accept-Charset"</js>, value);</code>
308    * 
309    * @param value The new header value.
310    * @return This object (for method chaining).
311    */
312   public RestClientBuilder acceptCharset(Object value) {
313      return header("Accept-Charset", value);
314   }
315
316   /**
317    * Sets the value for the <code>Accept-Encoding</code> request header.
318    * 
319    * <p>
320    * This is a shortcut for calling <code>header(<js>"Accept-Encoding"</js>, value);</code>
321    * 
322    * @param value The new header value.
323    * @return This object (for method chaining).
324    */
325   public RestClientBuilder acceptEncoding(Object value) {
326      return header("Accept-Encoding", value);
327   }
328
329   /**
330    * Sets the value for the <code>Accept-Language</code> request header.
331    * 
332    * <p>
333    * This is a shortcut for calling <code>header(<js>"Accept-Language"</js>, value);</code>
334    * 
335    * @param value The new header value.
336    * @return This object (for method chaining).
337    */
338   public RestClientBuilder acceptLanguage(Object value) {
339      return header("Accept-Language", value);
340   }
341
342   /**
343    * Sets the value for the <code>Authorization</code> request header.
344    * 
345    * <p>
346    * This is a shortcut for calling <code>header(<js>"Authorization"</js>, value);</code>
347    * 
348    * @param value The new header value.
349    * @return This object (for method chaining).
350    */
351   public RestClientBuilder authorization(Object value) {
352      return header("Authorization", value);
353   }
354
355   /**
356    * Sets the value for the <code>Cache-Control</code> request header.
357    * 
358    * <p>
359    * This is a shortcut for calling <code>header(<js>"Cache-Control"</js>, value);</code>
360    * 
361    * @param value The new header value.
362    * @return This object (for method chaining).
363    */
364   public RestClientBuilder cacheControl(Object value) {
365      return header("Cache-Control", value);
366   }
367
368   /**
369    * Sets the value for the <code>Connection</code> request header.
370    * 
371    * <p>
372    * This is a shortcut for calling <code>header(<js>"Connection"</js>, value);</code>
373    * 
374    * @param value The new header value.
375    * @return This object (for method chaining).
376    */
377   public RestClientBuilder connection(Object value) {
378      return header("Connection", value);
379   }
380
381   /**
382    * Sets the value for the <code>Content-Length</code> request header.
383    * 
384    * <p>
385    * This is a shortcut for calling <code>header(<js>"Content-Length"</js>, value);</code>
386    * 
387    * @param value The new header value.
388    * @return This object (for method chaining).
389    */
390   public RestClientBuilder contentLength(Object value) {
391      return header("Content-Length", value);
392   }
393
394   /**
395    * Sets the value for the <code>Content-Type</code> request header.
396    * 
397    * <p>
398    * This overrides the media type specified on the serializer, but is overridden by calling
399    * <code>header(<js>"Content-Type"</js>, value);</code>
400    * 
401    * @param value The new header value.
402    * @return This object (for method chaining).
403    */
404   public RestClientBuilder contentType(Object value) {
405      return header("Content-Type", value);
406   }
407
408   /**
409    * Sets the value for the <code>Date</code> request header.
410    * 
411    * <p>
412    * This is a shortcut for calling <code>header(<js>"Date"</js>, value);</code>
413    * 
414    * @param value The new header value.
415    * @return This object (for method chaining).
416    */
417   public RestClientBuilder date(Object value) {
418      return header("Date", value);
419   }
420
421   /**
422    * Sets the value for the <code>Expect</code> request header.
423    * 
424    * <p>
425    * This is a shortcut for calling <code>header(<js>"Expect"</js>, value);</code>
426    * 
427    * @param value The new header value.
428    * @return This object (for method chaining).
429    */
430   public RestClientBuilder expect(Object value) {
431      return header("Expect", value);
432   }
433
434   /**
435    * Sets the value for the <code>Forwarded</code> request header.
436    * 
437    * <p>
438    * This is a shortcut for calling <code>header(<js>"Forwarded"</js>, value);</code>
439    * 
440    * @param value The new header value.
441    * @return This object (for method chaining).
442    */
443   public RestClientBuilder forwarded(Object value) {
444      return header("Forwarded", value);
445   }
446
447   /**
448    * Sets the value for the <code>From</code> request header.
449    * 
450    * <p>
451    * This is a shortcut for calling <code>header(<js>"From"</js>, value);</code>
452    * 
453    * @param value The new header value.
454    * @return This object (for method chaining).
455    */
456   public RestClientBuilder from(Object value) {
457      return header("From", value);
458   }
459
460   /**
461    * Sets the value for the <code>Host</code> request header.
462    * 
463    * <p>
464    * This is a shortcut for calling <code>header(<js>"Host"</js>, value);</code>
465    * 
466    * @param value The new header value.
467    * @return This object (for method chaining).
468    */
469   public RestClientBuilder host(Object value) {
470      return header("Host", value);
471   }
472
473   /**
474    * Sets the value for the <code>If-Match</code> request header.
475    * 
476    * <p>
477    * This is a shortcut for calling <code>header(<js>"If-Match"</js>, value);</code>
478    * 
479    * @param value The new header value.
480    * @return This object (for method chaining).
481    */
482   public RestClientBuilder ifMatch(Object value) {
483      return header("If-Match", value);
484   }
485
486   /**
487    * Sets the value for the <code>If-Modified-Since</code> request header.
488    * 
489    * <p>
490    * This is a shortcut for calling <code>header(<js>"If-Modified-Since"</js>, value);</code>
491    * 
492    * @param value The new header value.
493    * @return This object (for method chaining).
494    */
495   public RestClientBuilder ifModifiedSince(Object value) {
496      return header("If-Modified-Since", value);
497   }
498
499   /**
500    * Sets the value for the <code>If-None-Match</code> request header.
501    * 
502    * <p>
503    * This is a shortcut for calling <code>header(<js>"If-None-Match"</js>, value);</code>
504    * 
505    * @param value The new header value.
506    * @return This object (for method chaining).
507    */
508   public RestClientBuilder ifNoneMatch(Object value) {
509      return header("If-None-Match", value);
510   }
511
512   /**
513    * Sets the value for the <code>If-Range</code> request header.
514    * 
515    * <p>
516    * This is a shortcut for calling <code>header(<js>"If-Range"</js>, value);</code>
517    * 
518    * @param value The new header value.
519    * @return This object (for method chaining).
520    */
521   public RestClientBuilder ifRange(Object value) {
522      return header("If-Range", value);
523   }
524
525   /**
526    * Sets the value for the <code>If-Unmodified-Since</code> request header.
527    * 
528    * <p>
529    * This is a shortcut for calling <code>header(<js>"If-Unmodified-Since"</js>, value);</code>
530    * 
531    * @param value The new header value.
532    * @return This object (for method chaining).
533    */
534   public RestClientBuilder ifUnmodifiedSince(Object value) {
535      return header("If-Unmodified-Since", value);
536   }
537
538   /**
539    * Sets the value for the <code>Max-Forwards</code> request header.
540    * 
541    * <p>
542    * This is a shortcut for calling <code>header(<js>"Max-Forwards"</js>, value);</code>
543    * 
544    * @param value The new header value.
545    * @return This object (for method chaining).
546    */
547   public RestClientBuilder maxForwards(Object value) {
548      return header("If-Unmodified-Since", value);
549   }
550
551   /**
552    * When called, <code>No-Trace: true</code> is added to requests.
553    * 
554    * <p>
555    * This gives the opportunity for the servlet to not log errors on invalid requests.
556    * This is useful for testing purposes when you don't want your log file to show lots of errors that are simply the
557    * results of testing.
558    * 
559    * @return This object (for method chaining).
560    */
561   public RestClientBuilder noTrace() {
562      return header("No-Trace", true);
563   }
564
565   /**
566    * Sets the value for the <code>Origin</code> request header.
567    * 
568    * <p>
569    * This is a shortcut for calling <code>header(<js>"Origin"</js>, value);</code>
570    * 
571    * @param value The new header value.
572    * @return This object (for method chaining).
573    */
574   public RestClientBuilder origin(Object value) {
575      return header("If-Unmodified-Since", value);
576   }
577
578   /**
579    * Sets the value for the <code>Pragma</code> request header.
580    * 
581    * <p>
582    * This is a shortcut for calling <code>header(<js>"Pragma"</js>, value);</code>
583    * 
584    * @param value The new header value.
585    * @return This object (for method chaining).
586    */
587   public RestClientBuilder pragma(Object value) {
588      return header("Pragma", value);
589   }
590
591   /**
592    * Sets the value for the <code>Proxy-Authorization</code> request header.
593    * 
594    * <p>
595    * This is a shortcut for calling <code>header(<js>"Proxy-Authorization"</js>, value);</code>
596    * 
597    * @param value The new header value.
598    * @return This object (for method chaining).
599    */
600   public RestClientBuilder proxyAuthorization(Object value) {
601      return header("Proxy-Authorization", value);
602   }
603
604   /**
605    * Sets the value for the <code>Range</code> request header.
606    * 
607    * <p>
608    * This is a shortcut for calling <code>header(<js>"Range"</js>, value);</code>
609    * 
610    * @param value The new header value.
611    * @return This object (for method chaining).
612    */
613   public RestClientBuilder range(Object value) {
614      return header("Range", value);
615   }
616
617   /**
618    * Sets the value for the <code>Referer</code> request header.
619    * 
620    * <p>
621    * This is a shortcut for calling <code>header(<js>"Referer"</js>, value);</code>
622    * 
623    * @param value The new header value.
624    * @return This object (for method chaining).
625    */
626   public RestClientBuilder referer(Object value) {
627      return header("Referer", value);
628   }
629
630   /**
631    * Sets the value for the <code>TE</code> request header.
632    * 
633    * <p>
634    * This is a shortcut for calling <code>header(<js>"TE"</js>, value);</code>
635    * 
636    * @param value The new header value.
637    * @return This object (for method chaining).
638    */
639   public RestClientBuilder te(Object value) {
640      return header("TE", value);
641   }
642
643   /**
644    * Sets the value for the <code>User-Agent</code> request header.
645    * 
646    * <p>
647    * This is a shortcut for calling <code>header(<js>"User-Agent"</js>, value);</code>
648    * 
649    * @param value The new header value.
650    * @return This object (for method chaining).
651    */
652   public RestClientBuilder userAgent(Object value) {
653      return header("User-Agent", value);
654   }
655
656   /**
657    * Sets the value for the <code>Upgrade</code> request header.
658    * 
659    * <p>
660    * This is a shortcut for calling <code>header(<js>"Upgrade"</js>, value);</code>
661    * 
662    * @param value The new header value.
663    * @return This object (for method chaining).
664    */
665   public RestClientBuilder upgrade(Object value) {
666      return header("Upgrade", value);
667   }
668
669   /**
670    * Sets the value for the <code>Via</code> request header.
671    * 
672    * <p>
673    * This is a shortcut for calling <code>header(<js>"Via"</js>, value);</code>
674    * 
675    * @param value The new header value.
676    * @return This object (for method chaining).
677    */
678   public RestClientBuilder via(Object value) {
679      return header("Via", value);
680   }
681
682   /**
683    * Sets the value for the <code>Warning</code> request header.
684    * 
685    * <p>
686    * This is a shortcut for calling <code>header(<js>"Warning"</js>, value);</code>
687    * 
688    * @param value The new header value.
689    * @return This object (for method chaining).
690    */
691   public RestClientBuilder warning(Object value) {
692      return header("Warning", value);
693   }
694
695
696   //--------------------------------------------------------------------------------
697   // Properties
698   //--------------------------------------------------------------------------------
699
700   /**
701    * Configuration property:  Executor service.
702    * 
703    * <p>
704    * Defines the executor service to use when calling future methods on the {@link RestCall} class.
705    * 
706    * <p>
707    * This executor service is used to create {@link Future} objects on the following methods:
708    * <ul>
709    *    <li>{@link RestCall#runFuture()}
710    *    <li>{@link RestCall#getResponseFuture(Class)}
711    *    <li>{@link RestCall#getResponseFuture(Type,Type...)}
712    *    <li>{@link RestCall#getResponseAsString()}
713    * </ul>
714    * 
715    * <p>
716    * The default executor service is a single-threaded {@link ThreadPoolExecutor} with a 30 second timeout
717    * and a queue size of 10.
718    * 
719    * <h5 class='section'>See Also:</h5>
720    * <ul>
721    *    <li class='jf'>{@link RestClient#RESTCLIENT_executorService}
722    *    <li class='jf'>{@link RestClient#RESTCLIENT_executorServiceShutdownOnClose}
723    * </ul>
724    * 
725    * @param executorService The executor service.
726    * @param shutdownOnClose Call {@link ExecutorService#shutdown()} when {@link RestClient#close()} is called.
727    * @return This object (for method chaining).
728    */
729   public RestClientBuilder executorService(ExecutorService executorService, boolean shutdownOnClose) {
730      set(RESTCLIENT_executorService, executorService);
731      set(RESTCLIENT_executorServiceShutdownOnClose, shutdownOnClose);
732      return this;
733   }
734
735   /**
736    * Configuration property:  Request headers.
737    * 
738    * <h5 class='section'>See Also:</h5>
739    * <ul>
740    *    <li class='jf'>{@link RestClient#RESTCLIENT_headers}
741    * </ul>
742    * 
743    * @param key The header name.
744    * @param value The header value.
745    * @return This object (for method chaining).
746    */
747   public RestClientBuilder header(String key, Object value) {
748      return addTo(RESTCLIENT_headers, key, value);
749   }
750
751   /**
752    * Configuration property:  Keep HttpClient open.
753    * 
754    * <p>
755    * Don't close this client when the {@link RestClient#close()} method is called.
756    * 
757    * <h5 class='section'>See Also:</h5>
758    * <ul>
759    *    <li class='jf'>{@link RestClient#RESTCLIENT_keepHttpClientOpen}
760    * </ul>
761    * 
762    * @param value 
763    *    The new value for this property.
764    *    <br>The default value is <jk>false</jk>.
765    * @return This object (for method chaining).
766    */
767   public RestClientBuilder keepHttpClientOpen(boolean value) {
768      return set(RESTCLIENT_keepHttpClientOpen, value);
769   }
770
771   /**
772    * Configuration property:  Call interceptors.
773    * 
774    * <p>
775    * Adds an interceptor that gets called immediately after a connection is made.
776    * 
777    * <h5 class='section'>See Also:</h5>
778    * <ul>
779    *    <li class='jf'>{@link RestClient#RESTCLIENT_interceptors}
780    * </ul>
781    * 
782    * @param value The values to add to this setting.
783    * @return This object (for method chaining).
784    */
785   public RestClientBuilder interceptors(RestCallInterceptor...value) {
786      return addTo(RESTCLIENT_interceptors, value);
787   }
788
789   /**
790    * Configuration property:  Parser.
791    * 
792    * <p>
793    * The parser to use for parsing POJOs in response bodies.
794    * 
795    * <h5 class='section'>See Also:</h5>
796    * <ul>
797    *    <li class='jf'>{@link RestClient#RESTCLIENT_parser}
798    * </ul>
799    * 
800    * @param value 
801    *    The new value for this setting.
802    *    <br>The default value is {@link JsonParser#DEFAULT}.
803    * @return This object (for method chaining).
804    */
805   public RestClientBuilder parser(Class<? extends Parser> value) {
806      return set(RESTCLIENT_parser, value);
807   }
808
809   /**
810    * Configuration property:  Parser.
811    * 
812    * <p>
813    * Same as {@link #parser(Parser)} except takes in a parser instance.
814    * 
815    * <h5 class='section'>See Also:</h5>
816    * <ul>
817    *    <li class='jf'>{@link RestClient#RESTCLIENT_parser}
818    * </ul>
819    * 
820    * @param value 
821    *    The new value for this setting.
822    *    <br>The default value is {@link JsonParser#DEFAULT}.
823    * @return This object (for method chaining).
824    */
825   public RestClientBuilder parser(Parser value) {    
826      return set(RESTCLIENT_parser, value);
827   }
828
829   /**
830    * Configuration property:  Part serializer.
831    * 
832    * <p>
833    * The serializer to use for serializing POJOs in form data, query parameters, headers, and path variables.
834    * 
835    * <h5 class='section'>See Also:</h5>
836    * <ul>
837    *    <li class='jf'>{@link RestClient#RESTCLIENT_partSerializer}
838    * </ul>
839    * 
840    * @param value 
841    *    The new value for this setting.
842    *    <br>The default value is {@link SimpleUonPartSerializer}.
843    * @return This object (for method chaining).
844    */
845   public RestClientBuilder partSerializer(Class<? extends HttpPartSerializer> value) {
846      return set(RESTCLIENT_partSerializer, value);
847   }
848
849   /**
850    * Configuration property:  Part serializer.
851    * 
852    * <p>
853    * Same as {@link #partSerializer(Class)} but takes in a parser instance.
854    * 
855    * <h5 class='section'>See Also:</h5>
856    * <ul>
857    *    <li class='jf'>{@link RestClient#RESTCLIENT_partSerializer}
858    * </ul>
859    * 
860    * @param value 
861    *    The new value for this setting.
862    *    <br>The default value is {@link SimpleUonPartSerializer}.
863    * @return This object (for method chaining).
864    */
865   public RestClientBuilder partSerializer(HttpPartSerializer value) {
866      return set(RESTCLIENT_partSerializer, value);
867   }
868
869   /**
870    * Make HTTP calls retryable if an error response (>=400) is received.
871    * 
872    * <h5 class='section'>See Also:</h5>
873    * <ul>
874    *    <li class='jf'>{@link RestClient#RESTCLIENT_retries}
875    *    <li class='jf'>{@link RestClient#RESTCLIENT_retryInterval}
876    *    <li class='jf'>{@link RestClient#RESTCLIENT_retryOn}
877    * </ul>
878    * 
879    * @param retries The number of retries to attempt.
880    * @param interval The time in milliseconds between attempts.
881    * @param retryOn
882    *    Optional object used for determining whether a retry should be attempted.
883    *    If <jk>null</jk>, uses {@link RetryOn#DEFAULT}.
884    * @return This object (for method chaining).
885    */
886   public RestClientBuilder retryable(int retries, int interval, RetryOn retryOn) {
887      set(RESTCLIENT_retries, retries);
888      set(RESTCLIENT_retryInterval, interval);
889      set(RESTCLIENT_retryOn, retryOn);
890      return this;
891   }
892
893   /**
894    * Configuration property:  Root URI.
895    * 
896    * <p>
897    * When set, relative URL strings passed in through the various rest call methods (e.g. {@link RestClient#doGet(Object)}
898    * will be prefixed with the specified root.
899    * <br>This root URL is ignored on those methods if you pass in a {@link URL}, {@link URI}, or an absolute URL string.
900    * 
901    * <h5 class='section'>See Also:</h5>
902    * <ul>
903    *    <li class='jf'>{@link RestClient#RESTCLIENT_rootUri}
904    * </ul>
905    * 
906    * @param value
907    *    The root URL to prefix to relative URL strings.
908    *    <br>Trailing slashes are trimmed.
909    *    <br>Usually a <code>String</code> but you can also pass in <code>URI</code> and <code>URL</code> objects as well.
910    * @return This object (for method chaining).
911    */
912   public RestClientBuilder rootUrl(Object value) {
913      return set(RESTCLIENT_rootUri, value);
914   }
915
916   /**
917    * Configuration property:  Request query parameters.
918    * 
919    * <h5 class='section'>See Also:</h5>
920    * <ul>
921    *    <li class='jf'>{@link RestClient#RESTCLIENT_query}
922    * </ul>
923    * 
924    * @param key The query parameter name.
925    * @param value The query parameter value value.
926    * @return This object (for method chaining).
927    */
928   public RestClientBuilder query(String key, Object value) {
929      return addTo(RESTCLIENT_query, key, value);
930   }
931
932   /**
933    * Configuration property:  Serializer.
934    * 
935    * <p>
936    * The serializer to use for serializing POJOs in request bodies.
937    * 
938    * <h5 class='section'>See Also:</h5>
939    * <ul>
940    *    <li class='jf'>{@link RestClient#RESTCLIENT_serializer}
941    * </ul>
942    * 
943    * @param value 
944    *    The new value for this setting.
945    *    <br>The default is {@link JsonSerializer}.
946    * @return This object (for method chaining).
947    */
948   public RestClientBuilder serializer(Class<? extends Serializer> value) {
949      return set(RESTCLIENT_serializer, value);
950   }
951
952   /**
953    * Configuration property:  Serializer.
954    * 
955    * <p>
956    * Same as {@link #serializer(Class)} but takes in a serializer instance.
957    * 
958    * <h5 class='section'>See Also:</h5>
959    * <ul>
960    *    <li class='jf'>{@link RestClient#RESTCLIENT_serializer}
961    * </ul>
962    * 
963    * @param value 
964    *    The new value for this setting.
965    *    <br>The default is {@link JsonSerializer}.
966    * @return This object (for method chaining).
967    */
968   public RestClientBuilder serializer(Serializer value) {
969      return set(RESTCLIENT_serializer, value);
970   }
971
972   /**
973    * Configuration property:  Abridged output.
974    * 
975    * <p>
976    * When enabled, it is assumed that the parser knows the exact Java POJO type being parsed, and therefore top-level
977    * type information that might normally be included to determine the data type will not be serialized.
978    * 
979    * <h5 class='section'>See Also:</h5>
980    * <ul>
981    *    <li class='jf'>{@link Serializer#SERIALIZER_abridged}
982    * </ul>
983    * 
984    * @param value 
985    *    The new value for this property.
986    *    <br>The default is <jk>false</jk>.
987    * @return This object (for method chaining).
988    */
989   public RestClientBuilder abridged(boolean value) {
990      return set(SERIALIZER_abridged, value);
991   }
992
993   /**
994    * Configuration property:  Abridged output.
995    * 
996    * <p>
997    * Shortcut for calling <code>abridged(<jk>true</jk>)</code>.
998    * 
999    * <h5 class='section'>See Also:</h5>
1000    * <ul>
1001    *    <li class='jf'>{@link Serializer#SERIALIZER_abridged}
1002    * </ul>
1003    * 
1004    * @return This object (for method chaining).
1005    */
1006   public RestClientBuilder abridged() {
1007      return set(SERIALIZER_abridged, true);
1008   }
1009
1010   /**
1011    * Configuration property:  Add <js>"_type"</js> properties when needed.
1012    * 
1013    * <p>
1014    * If <jk>true</jk>, then <js>"_type"</js> properties will be added to beans if their type cannot be inferred
1015    * through reflection.
1016    * 
1017    * <h5 class='section'>See Also:</h5>
1018    * <ul>
1019    *    <li class='jf'>{@link Serializer#SERIALIZER_addBeanTypeProperties}
1020    * </ul>
1021    * 
1022    * @param value 
1023    *    The new value for this property.
1024    *    <br>The default is <jk>true</jk>.
1025    * @return This object (for method chaining).
1026    */
1027   public RestClientBuilder addBeanTypeProperties(boolean value) {
1028      return set(SERIALIZER_addBeanTypeProperties, value);
1029   }
1030
1031   /**
1032    * Configuration property:  Automatically detect POJO recursions.
1033    * 
1034    * <p>
1035    * Specifies that recursions should be checked for during serialization.
1036    * 
1037    * <h5 class='section'>Notes:</h5>
1038    * <ul class='spaced-list'>
1039    *    <li>
1040    *       Checking for recursion can cause a small performance penalty.
1041    * </ul>
1042    * 
1043    * <h5 class='section'>See Also:</h5>
1044    * <ul>
1045    *    <li class='jf'>{@link Serializer#SERIALIZER_detectRecursions}
1046    * </ul>
1047    * 
1048    * @param value 
1049    *    The new value for this property.
1050    *    <br>The default is <jk>false</jk>.
1051    * @return This object (for method chaining).
1052    */
1053   public RestClientBuilder detectRecursions(boolean value) {
1054      return set(SERIALIZER_detectRecursions, value);
1055   }
1056
1057   /**
1058    * Configuration property:  Automatically detect POJO recursions.
1059    * 
1060    * <p>
1061    * Shortcut for calling <code>detectRecursions(<jk>true</jk>)</code>.
1062    * 
1063    * <h5 class='section'>See Also:</h5>
1064    * <ul>
1065    *    <li class='jf'>{@link Serializer#SERIALIZER_detectRecursions}
1066    * </ul>
1067    * 
1068    * @return This object (for method chaining).
1069    */
1070   public RestClientBuilder detectRecursions() {
1071      return set(SERIALIZER_detectRecursions, true);
1072   }
1073
1074   /**
1075    * Configuration property:  Ignore recursion errors.
1076    * 
1077    * <p>
1078    * If <jk>true</jk>, when we encounter the same object when serializing a tree, we set the value to <jk>null</jk>.
1079    * Otherwise, an exception is thrown.
1080    * 
1081    * <h5 class='section'>Notes:</h5>
1082    * <ul class='spaced-list'>
1083    *    <li>
1084    *       Checking for recursion can cause a small performance penalty.
1085    * </ul>
1086    * 
1087    * <h5 class='section'>See Also:</h5>
1088    * <ul>
1089    *    <li class='jf'>{@link Serializer#SERIALIZER_ignoreRecursions}
1090    * </ul>
1091    * 
1092    * @param value 
1093    *    The new value for this property.
1094    *    <br>The default is <jk>false</jk>.
1095    * @return This object (for method chaining).
1096    */
1097   public RestClientBuilder ignoreRecursions(boolean value) {
1098      return set(SERIALIZER_ignoreRecursions, value);
1099   }
1100
1101   /**
1102    * Configuration property:  Ignore recursion errors.
1103    * 
1104    * <p>
1105    * Shortcut for calling <code>ignoreRecursions(<jk>true</jk>)</code>.
1106    * 
1107    * <h5 class='section'>See Also:</h5>
1108    * <ul>
1109    *    <li class='jf'>{@link Serializer#SERIALIZER_ignoreRecursions}
1110    * </ul>
1111    * 
1112    * @return This object (for method chaining).
1113    */
1114   public RestClientBuilder ignoreRecursions() {
1115      return set(SERIALIZER_ignoreRecursions, true);
1116   }
1117
1118   /**
1119    * Configuration property:  Initial depth.
1120    * 
1121    * <p>
1122    * The initial indentation level at the root.
1123    * 
1124    * <h5 class='section'>See Also:</h5>
1125    * <ul>
1126    *    <li class='jf'>{@link Serializer#SERIALIZER_initialDepth}
1127    * </ul>
1128    * 
1129    * @param value 
1130    *    The new value for this property.
1131    *    <br>The default is <code>0</code>.
1132    * @return This object (for method chaining).
1133    */
1134   public RestClientBuilder initialDepth(int value) {
1135      return set(SERIALIZER_initialDepth, value);
1136   }
1137
1138   /**
1139    * Configuration property:  Serializer listener.
1140    * 
1141    * <p>
1142    * Class used to listen for errors and warnings that occur during serialization.
1143    * 
1144    * <h5 class='section'>See Also:</h5>
1145    * <ul>
1146    *    <li class='jf'>{@link Serializer#SERIALIZER_listener}
1147    * </ul>
1148    * 
1149    * @param value 
1150    *    The new value for this property.
1151    * @return This object (for method chaining).
1152    */
1153   public RestClientBuilder listenerS(Class<? extends SerializerListener> value) {
1154      return set(SERIALIZER_listener, value);
1155   }
1156
1157   /**
1158    * Configuration property:  Max serialization depth.
1159    * 
1160    * <p>
1161    * Abort serialization if specified depth is reached in the POJO tree.
1162    * <br>If this depth is exceeded, an exception is thrown.
1163    * <br>This prevents stack overflows from occurring when trying to serialize models with recursive references.
1164    * 
1165    * <h5 class='section'>See Also:</h5>
1166    * <ul>
1167    *    <li class='jf'>{@link Serializer#SERIALIZER_maxDepth}
1168    * </ul>
1169    * 
1170    * @param value 
1171    *    The new value for this property.
1172    *    <br>The default is <code>100</code>.
1173    * @return This object (for method chaining).
1174    */
1175   public RestClientBuilder maxDepth(int value) {
1176      return set(SERIALIZER_maxDepth, value);
1177   }
1178
1179   /**
1180    * Configuration property:  Maximum indentation.
1181    * 
1182    * <p>
1183    * Specifies the maximum indentation level in the serialized document.
1184    * 
1185    * <h5 class='section'>See Also:</h5>
1186    * <ul>
1187    *    <li class='jf'>{@link Serializer#SERIALIZER_maxIndent}
1188    * </ul>
1189    * 
1190    * @param value 
1191    *    The new value for this property.
1192    *    <br>The default is <code>100</code>.
1193    * @return This object (for method chaining).
1194    */
1195   public RestClientBuilder maxIndent(boolean value) {
1196      return set(SERIALIZER_maxIndent, value);
1197   }
1198
1199   /**
1200    * Configuration property:  Quote character.
1201    * 
1202    * <p>
1203    * This is the character used for quoting attributes and values.
1204    * 
1205    * <h5 class='section'>See Also:</h5>
1206    * <ul>
1207    *    <li class='jf'>{@link Serializer#SERIALIZER_quoteChar}
1208    * </ul>
1209    * 
1210    * @param value 
1211    *    The new value for this property.
1212    *    <br>The default is <js>'"'</js>.
1213    * @return This object (for method chaining).
1214    */
1215   public RestClientBuilder quoteChar(char value) {
1216      return set(SERIALIZER_quoteChar, value);
1217   }
1218
1219   /**
1220    * Configuration property:  Quote character.
1221    * 
1222    * <p>
1223    * Shortcut for calling <code>quoteChar(<js>'\''</js>)</code>.
1224    * 
1225    * <h5 class='section'>See Also:</h5>
1226    * <ul>
1227    *    <li class='jf'>{@link Serializer#SERIALIZER_quoteChar}
1228    * </ul>
1229    * 
1230    * @return This object (for method chaining).
1231    */
1232   public RestClientBuilder sq() {
1233      return set(SERIALIZER_quoteChar, '\'');
1234   }
1235
1236   /**
1237    * Configuration property:  Sort arrays and collections alphabetically.
1238    * 
1239    * <p>
1240    * Copies and sorts the contents of arrays and collections before serializing them.
1241    * 
1242    * <h5 class='section'>See Also:</h5>
1243    * <ul>
1244    *    <li class='jf'>{@link Serializer#SERIALIZER_sortCollections}
1245    * </ul>
1246    * 
1247    * @param value 
1248    *    The new value for this property.
1249    *    <br>The default is <jk>false</jk>.
1250    * @return This object (for method chaining).
1251    */
1252   public RestClientBuilder sortCollections(boolean value) {
1253      return set(SERIALIZER_sortCollections, value);
1254   }
1255
1256   /**
1257    * Configuration property:  Sort arrays and collections alphabetically.
1258    * 
1259    * <p>
1260    * Shortcut for calling <code>sortCollections(<jk>true</jk>)</code>.
1261    * 
1262    * <h5 class='section'>See Also:</h5>
1263    * <ul>
1264    *    <li class='jf'>{@link Serializer#SERIALIZER_sortCollections}
1265    * </ul>
1266    * 
1267    * @return This object (for method chaining).
1268    */
1269   public RestClientBuilder sortCollections() {
1270      return set(SERIALIZER_sortCollections, true);
1271   }
1272
1273   /**
1274    * Sets the {@link Serializer#SERIALIZER_sortMaps} property on all serializers in this group.
1275    * 
1276    * <p>
1277    * Copies and sorts the contents of maps before serializing them.
1278    * 
1279    * <h5 class='section'>See Also:</h5>
1280    * <ul>
1281    *    <li class='jf'>{@link Serializer#SERIALIZER_sortMaps}
1282    * </ul>
1283    * 
1284    * @param value The new value for this property.
1285    * @return This object (for method chaining).
1286    */
1287   public RestClientBuilder sortMaps(boolean value) {
1288      return set(SERIALIZER_sortMaps, value);
1289   }
1290
1291   /**
1292    * Configuration property:  Sort maps alphabetically.
1293    * 
1294    * <p>
1295    * Shortcut for calling <code>sortMaps(<jk>true</jk>)</code>.
1296    * 
1297    * <h5 class='section'>See Also:</h5>
1298    * <ul>
1299    *    <li class='jf'>{@link Serializer#SERIALIZER_sortMaps}
1300    * </ul>
1301    * 
1302    * @return This object (for method chaining).
1303    */
1304   public RestClientBuilder sortMaps() {
1305      return set(SERIALIZER_sortMaps, true);
1306   }
1307
1308   /**
1309    * Configuration property:  Trim empty lists and arrays.
1310    * 
1311    * <p>
1312    * If <jk>true</jk>, empty list values will not be serialized to the output.
1313    * 
1314    * <h5 class='section'>See Also:</h5>
1315    * <ul>
1316    *    <li class='jf'>{@link Serializer#SERIALIZER_trimEmptyCollections}
1317    * </ul>
1318    * 
1319    * @param value 
1320    *    The new value for this property.
1321    *    <br>The default is <jk>false</jk>.
1322    * @return This object (for method chaining).
1323    */
1324   public RestClientBuilder trimEmptyCollections(boolean value) {
1325      return set(SERIALIZER_trimEmptyCollections, value);
1326   }
1327
1328   /**
1329    * Configuration property:  Trim empty lists and arrays.
1330    * 
1331    * <p>
1332    * Shortcut for calling <code>trimEmptyCollections(<jk>true</jk>)</code>.
1333    * 
1334    * <h5 class='section'>See Also:</h5>
1335    * <ul>
1336    *    <li class='jf'>{@link Serializer#SERIALIZER_trimEmptyCollections}
1337    * </ul>
1338    * 
1339    * @return This object (for method chaining).
1340    */
1341   public RestClientBuilder trimEmptyCollections() {
1342      return set(SERIALIZER_trimEmptyCollections, true);
1343   }
1344
1345   /**
1346    * Configuration property:  Trim empty maps.
1347    * 
1348    * <p>
1349    * If <jk>true</jk>, empty map values will not be serialized to the output.
1350    * 
1351    * <h5 class='section'>See Also:</h5>
1352    * <ul>
1353    *    <li class='jf'>{@link Serializer#SERIALIZER_trimEmptyMaps}
1354    * </ul>
1355    * 
1356    * @param value 
1357    *    The new value for this property.
1358    *    <br>The default is <jk>false</jk>.
1359    * @return This object (for method chaining).
1360    */
1361   public RestClientBuilder trimEmptyMaps(boolean value) {
1362      return set(SERIALIZER_trimEmptyMaps, value);
1363   }
1364
1365   /**
1366    * Configuration property:  Trim empty maps.
1367    * 
1368    * <p>
1369    * Shortcut for calling <code>trimEmptyMaps(<jk>true</jk>)</code>.
1370    * 
1371    * <h5 class='section'>See Also:</h5>
1372    * <ul>
1373    *    <li class='jf'>{@link Serializer#SERIALIZER_trimEmptyMaps}
1374    * </ul>
1375    * 
1376    * @return This object (for method chaining).
1377    */
1378   public RestClientBuilder trimEmptyMaps() {
1379      return set(SERIALIZER_trimEmptyMaps, true);
1380   }
1381
1382   /**
1383    * Configuration property:  Trim null bean property values.
1384    * 
1385    * <p>
1386    * If <jk>true</jk>, null bean values will not be serialized to the output.
1387    * 
1388    * <h5 class='section'>See Also:</h5>
1389    * <ul>
1390    *    <li class='jf'>{@link Serializer#SERIALIZER_trimNullProperties}
1391    * </ul>
1392    * 
1393    * @param value 
1394    *    The new value for this property.
1395    *    <br>The default is <jk>true</jk>.
1396    * @return This object (for method chaining).
1397    */
1398   public RestClientBuilder trimNullProperties(boolean value) {
1399      return set(SERIALIZER_trimNullProperties, value);
1400   }
1401
1402   /**
1403    * Configuration property:  Trim strings.
1404    * 
1405    * <p>
1406    * If <jk>true</jk>, string values will be trimmed of whitespace using {@link String#trim()} before being serialized.
1407    * 
1408    * <h5 class='section'>See Also:</h5>
1409    * <ul>
1410    *    <li class='jf'>{@link Serializer#SERIALIZER_trimStrings}
1411    * </ul>
1412    * 
1413    * @param value 
1414    *    The new value for this property.
1415    *    <br>The default is <jk>false</jk>.
1416    * @return This object (for method chaining).
1417    */
1418   public RestClientBuilder trimStringsS(boolean value) {
1419      return set(SERIALIZER_trimStrings, value);
1420   }
1421
1422   /**
1423    * Configuration property:  Trim strings.
1424    * 
1425    * <p>
1426    * Shortcut for calling <code>trimStrings(<jk>true</jk>)</code>.
1427    * 
1428    * <h5 class='section'>See Also:</h5>
1429    * <ul>
1430    *    <li class='jf'>{@link Serializer#SERIALIZER_trimStrings}
1431    * </ul>
1432    * 
1433    * @return This object (for method chaining).
1434    */
1435   public RestClientBuilder trimStringsS() {
1436      return set(SERIALIZER_trimStrings, true);
1437   }
1438
1439   /**
1440    * Configuration property:  URI context bean.
1441    * 
1442    * <p>
1443    * Bean used for resolution of URIs to absolute or root-relative form.
1444    * 
1445    * <h5 class='section'>See Also:</h5>
1446    * <ul>
1447    *    <li class='jf'>{@link Serializer#SERIALIZER_uriContext}
1448    * </ul>
1449    * 
1450    * @param value The new value for this property.
1451    * @return This object (for method chaining).
1452    */
1453   public RestClientBuilder uriContext(UriContext value) {
1454      return set(SERIALIZER_uriContext, value);
1455   }
1456
1457   /**
1458    * Configuration property:  URI relativity.
1459    * 
1460    * <p>
1461    * Defines what relative URIs are relative to when serializing URI/URL objects.
1462    * 
1463    * <h5 class='section'>See Also:</h5>
1464    * <ul>
1465    *    <li class='jf'>{@link Serializer#SERIALIZER_uriRelativity}
1466    * </ul>
1467    * 
1468    * @param value 
1469    *    The new value for this property.
1470    *    <br>The default is {@link UriRelativity#RESOURCE}
1471    * @return This object (for method chaining).
1472    */
1473   public RestClientBuilder uriRelativity(UriRelativity value) {
1474      return set(SERIALIZER_uriRelativity, value);
1475   }
1476
1477   /**
1478    * Configuration property:  URI resolution.
1479    * 
1480    * <p>
1481    * Defines the resolution level for URIs when serializing URI/URL objects.
1482    * 
1483    * <h5 class='section'>See Also:</h5>
1484    * <ul>
1485    *    <li class='jf'>{@link Serializer#SERIALIZER_uriResolution}
1486    * </ul>
1487    * 
1488    * @param value 
1489    *    The new value for this property.
1490    *    <br>The default is {@link UriResolution#NONE}
1491    * @return This object (for method chaining).
1492    */
1493   public RestClientBuilder uriResolution(UriResolution value) {
1494      return set(SERIALIZER_uriResolution, value);
1495   }
1496
1497   /**
1498    * Configuration property:  Use whitespace.
1499    * 
1500    * <p>
1501    * If <jk>true</jk>, newlines and indentation and spaces are added to the output to improve readability.
1502    * 
1503    * <h5 class='section'>See Also:</h5>
1504    * <ul>
1505    *    <li class='jf'>{@link Serializer#SERIALIZER_useWhitespace}
1506    * </ul>
1507    * 
1508    * @param value 
1509    *    The new value for this property.
1510    *    <br>The default is <jk>false</jk>.
1511    * @return This object (for method chaining).
1512    */
1513   public RestClientBuilder useWhitespace(boolean value) {
1514      return set(SERIALIZER_useWhitespace, value);
1515   }
1516   
1517   /**
1518    * Configuration property:  Use whitespace.
1519    * 
1520    * <p>
1521    * Shortcut for calling <code>useWhitespace(<jk>true</jk>)</code>.
1522    * 
1523    * <h5 class='section'>See Also:</h5>
1524    * <ul>
1525    *    <li class='jf'>{@link Serializer#SERIALIZER_useWhitespace}
1526    * </ul>
1527    * @return This object (for method chaining).
1528    */
1529   public RestClientBuilder useWhitespace() {
1530      return set(SERIALIZER_useWhitespace, true);
1531   }
1532
1533   /**
1534    * Configuration property:  Use whitespace.
1535    * 
1536    * <p>
1537    * Shortcut for calling <code>useWhitespace(<jk>true</jk>)</code>.
1538    * 
1539    * <h5 class='section'>See Also:</h5>
1540    * <ul>
1541    *    <li class='jf'>{@link Serializer#SERIALIZER_useWhitespace}
1542    * </ul>
1543    * 
1544    * @return This object (for method chaining).
1545    */
1546   public RestClientBuilder ws() {
1547      return set(SERIALIZER_useWhitespace, true);
1548   }
1549
1550   /**
1551    * Configuration property:  Auto-close streams.
1552    * 
1553    * If <jk>true</jk>, <l>InputStreams</l> and <l>Readers</l> passed into parsers will be closed
1554    * after parsing is complete.
1555    * 
1556    * <h5 class='section'>See Also:</h5>
1557    * <ul>
1558    *    <li class='jf'>{@link Parser#PARSER_autoCloseStreams}
1559    * </ul>
1560    * 
1561    * @param value 
1562    *    The new value for this property.
1563    *    <br>The default value is <jk>false</jk>.
1564    * @return This object (for method chaining).
1565    */
1566   public RestClientBuilder autoCloseStreams(boolean value) {
1567      return set(PARSER_autoCloseStreams, value);
1568   }
1569
1570   /**
1571    * Configuration property:  Auto-close streams.
1572    * 
1573    * <p>
1574    * Shortcut for calling <code>autoCloseStreams(<jk>true</jk>)</code>.
1575    * 
1576    * <h5 class='section'>See Also:</h5>
1577    * <ul>
1578    *    <li class='jf'>{@link Parser#PARSER_autoCloseStreams}
1579    * </ul>
1580    * 
1581    * @return This object (for method chaining).
1582    */
1583   public RestClientBuilder autoCloseStreams() {
1584      return set(PARSER_autoCloseStreams, true);
1585   }
1586
1587   /**
1588    * Configuration property:  File charset.
1589    * 
1590    * <p>
1591    * The character set to use for reading <code>Files</code> from the file system.
1592    * 
1593    * <h5 class='section'>See Also:</h5>
1594    * <ul>
1595    *    <li class='jf'>{@link Parser#PARSER_fileCharset}
1596    * </ul>
1597    * 
1598    * @param value 
1599    *    The new value for this property.
1600    *    <br>The default value is <js>"DEFAULT"</js> which causes the system default to be used.
1601    * @return This object (for method chaining).
1602    */
1603   public RestClientBuilder fileCharset(String value) {
1604      return set(PARSER_fileCharset, value);
1605   }
1606
1607   /**
1608    * Configuration property:  Input stream charset.
1609    * 
1610    * <p>
1611    * The character set to use for converting <code>InputStreams</code> and byte arrays to readers.
1612    * 
1613    * <h5 class='section'>See Also:</h5>
1614    * <ul>
1615    *    <li class='jf'>{@link Parser#PARSER_inputStreamCharset}
1616    * </ul>
1617    * 
1618    * @param value 
1619    *    The new value for this property.
1620    *    <br>The default value is <js>"UTF-8"</js>.
1621    * @return This object (for method chaining).
1622    */
1623   public RestClientBuilder inputStreamCharset(String value) {
1624      return set(PARSER_inputStreamCharset, value);
1625   }
1626
1627   /**
1628    * Configuration property:  Parser listener.
1629    * 
1630    * <p>
1631    * Class used to listen for errors and warnings that occur during parsing.
1632    * 
1633    * <h5 class='section'>See Also:</h5>
1634    * <ul>
1635    *    <li class='jf'>{@link Parser#PARSER_listener}
1636    * </ul>
1637    * 
1638    * @param value The new value for this property.
1639    * @return This object (for method chaining).
1640    */
1641   public RestClientBuilder listenerP(Class<? extends ParserListener> value) {
1642      return set(PARSER_listener, value);
1643   }
1644
1645   /**
1646    * Configuration property:  Strict mode.
1647    * 
1648    * <p>
1649    * If <jk>true</jk>, strict mode for the parser is enabled.
1650    * 
1651    * <h5 class='section'>See Also:</h5>
1652    * <ul>
1653    *    <li class='jf'>{@link Parser#PARSER_strict}
1654    * </ul>
1655    * 
1656    * @param value 
1657    *    The new value for this property.
1658    *    <br>The default value is <jk>false</jk>.
1659    * @return This object (for method chaining).
1660    */
1661   public RestClientBuilder strict(boolean value) {
1662      return set(PARSER_strict, value);
1663   }
1664
1665   /**
1666    * Configuration property:  Strict mode.
1667    * 
1668    * <p>
1669    * Shortcut for calling <code>strict(<jk>true</jk>)</code>.
1670    * 
1671    * <h5 class='section'>See Also:</h5>
1672    * <ul>
1673    *    <li class='jf'>{@link Parser#PARSER_strict}
1674    * </ul>
1675    * 
1676    * @return This object (for method chaining).
1677    */
1678   public RestClientBuilder strict() {
1679      return set(PARSER_strict, true);
1680   }
1681
1682   /**
1683    * Configuration property:  Trim parsed strings.
1684    * 
1685    * <p>
1686    * If <jk>true</jk>, string values will be trimmed of whitespace using {@link String#trim()} before being added to
1687    * the POJO.
1688    * 
1689    * <h5 class='section'>See Also:</h5>
1690    * <ul>
1691    *    <li class='jf'>{@link Parser#PARSER_trimStrings}
1692    * </ul>
1693    * 
1694    * @param value 
1695    *    The new value for this property.
1696    *    <br>The default value is <jk>false</jk>.
1697    * @return This object (for method chaining).
1698    */
1699   public RestClientBuilder trimStringsP(boolean value) {
1700      return set(PARSER_trimStrings, value);
1701   }
1702
1703   /**
1704    * Configuration property:  Trim parsed strings.
1705    * 
1706    * <p>
1707    * Shortcut for calling <code>trimStrings(<jk>true</jk>)</code>.
1708    * 
1709    * <h5 class='section'>See Also:</h5>
1710    * <ul>
1711    *    <li class='jf'>{@link Parser#PARSER_trimStrings}
1712    * </ul>
1713    * 
1714    * @return This object (for method chaining).
1715    */
1716   public RestClientBuilder trimStringsP() {
1717      return set(PARSER_trimStrings, true);
1718   }
1719
1720   /**
1721    * Configuration property:  Unbuffered.
1722    * 
1723    * If <jk>true</jk>, don't use internal buffering during parsing.
1724    * 
1725    * <h5 class='section'>See Also:</h5>
1726    * <ul>
1727    *    <li class='jf'>{@link Parser#PARSER_unbuffered}
1728    * </ul>
1729    * 
1730    * @param value 
1731    *    The new value for this property.
1732    *    <br>The default value is <jk>false</jk>.
1733    * @return This object (for method chaining).
1734    */
1735   public RestClientBuilder unbuffered(boolean value) {
1736      return set(PARSER_unbuffered, value);
1737   }
1738
1739   /**
1740    * Configuration property:  Unbuffered.
1741    * 
1742    * <p>
1743    * Shortcut for calling <code>unbuffered(<jk>true</jk>)</code>.
1744    * 
1745    * <h5 class='section'>See Also:</h5>
1746    * <ul>
1747    *    <li class='jf'>{@link Parser#PARSER_unbuffered}
1748    * </ul>
1749    * 
1750    * @return This object (for method chaining).
1751    */
1752   public RestClientBuilder unbuffered() {
1753      return set(PARSER_unbuffered, true);
1754   }
1755
1756   /**
1757    * Configuration property:  Parameter format.
1758    * 
1759    * <h5 class='section'>See Also:</h5>
1760    * <ul>
1761    *    <li class='jf'>{@link UonSerializer#UON_paramFormat}
1762    * </ul>
1763    * 
1764    * @param value The new value for this property.
1765    * @return This object (for method chaining).
1766    */
1767   public RestClientBuilder paramFormat(String value) {
1768      return set(UON_paramFormat, value);
1769   }
1770
1771   /**
1772    * Configuration property:  Parameter format.
1773    * 
1774    * <h5 class='section'>See Also:</h5>
1775    * <ul>
1776    *    <li class='jf'>{@link UonSerializer#UON_paramFormat}
1777    * </ul>
1778    * 
1779    * @return This object (for method chaining).
1780    */
1781   public RestClientBuilder paramFormatPlain() {
1782      return set(UON_paramFormat, "PLAINTEXT");
1783   }
1784
1785   @Override /* BeanContextBuilder */
1786   public RestClientBuilder beansRequireDefaultConstructor(boolean value) {
1787      super.beansRequireDefaultConstructor(value);
1788      return this;
1789   }
1790
1791   @Override /* BeanContextBuilder */
1792   public RestClientBuilder beansRequireDefaultConstructor() {
1793      super.beansRequireDefaultConstructor();
1794      return this;
1795   }
1796
1797   @Override /* BeanContextBuilder */
1798   public RestClientBuilder beansRequireSerializable(boolean value) {
1799      super.beansRequireSerializable(value);
1800      return this;
1801   }
1802
1803   @Override /* BeanContextBuilder */
1804   public RestClientBuilder beansRequireSerializable() {
1805      super.beansRequireSerializable();
1806      return this;
1807   }
1808
1809   @Override /* BeanContextBuilder */
1810   public RestClientBuilder beansRequireSettersForGetters(boolean value) {
1811      super.beansRequireSettersForGetters(value);
1812      return this;
1813   }
1814
1815   @Override /* BeanContextBuilder */
1816   public RestClientBuilder beansRequireSettersForGetters() {
1817      super.beansRequireSettersForGetters();
1818      return this;
1819   }
1820
1821   @Override /* BeanContextBuilder */
1822   public RestClientBuilder beansRequireSomeProperties(boolean value) {
1823      super.beansRequireSomeProperties(value);
1824      return this;
1825   }
1826
1827   @Override /* BeanContextBuilder */
1828   public RestClientBuilder beanMapPutReturnsOldValue(boolean value) {
1829      super.beanMapPutReturnsOldValue(value);
1830      return this;
1831   }
1832
1833   @Override /* BeanContextBuilder */
1834   public RestClientBuilder beanMapPutReturnsOldValue() {
1835      super.beanMapPutReturnsOldValue();
1836      return this;
1837   }
1838
1839   @Override /* BeanContextBuilder */
1840   public RestClientBuilder beanConstructorVisibility(Visibility value) {
1841      super.beanConstructorVisibility(value);
1842      return this;
1843   }
1844
1845   @Override /* BeanContextBuilder */
1846   public RestClientBuilder beanClassVisibility(Visibility value) {
1847      super.beanClassVisibility(value);
1848      return this;
1849   }
1850
1851   @Override /* BeanContextBuilder */
1852   public RestClientBuilder beanFieldVisibility(Visibility value) {
1853      super.beanFieldVisibility(value);
1854      return this;
1855   }
1856
1857   @Override /* BeanContextBuilder */
1858   public RestClientBuilder beanMethodVisibility(Visibility value) {
1859      super.beanMethodVisibility(value);
1860      return this;
1861   }
1862
1863   @Override /* BeanContextBuilder */
1864   public RestClientBuilder useJavaBeanIntrospector(boolean value) {
1865      super.useJavaBeanIntrospector(value);
1866      return this;
1867   }
1868
1869   @Override /* BeanContextBuilder */
1870   public RestClientBuilder useJavaBeanIntrospector() {
1871      super.useJavaBeanIntrospector();
1872      return this;
1873   }
1874
1875   @Override /* BeanContextBuilder */
1876   public RestClientBuilder useInterfaceProxies(boolean value) {
1877      super.useInterfaceProxies(value);
1878      return this;
1879   }
1880
1881   @Override /* BeanContextBuilder */
1882   public RestClientBuilder ignoreUnknownBeanProperties(boolean value) {
1883      super.ignoreUnknownBeanProperties(value);
1884      return this;
1885   }
1886
1887   @Override /* BeanContextBuilder */
1888   public RestClientBuilder ignoreUnknownBeanProperties() {
1889      super.ignoreUnknownBeanProperties();
1890      return this;
1891   }
1892
1893   @Override /* BeanContextBuilder */
1894   public RestClientBuilder ignoreUnknownNullBeanProperties(boolean value) {
1895      super.ignoreUnknownNullBeanProperties(value);
1896      return this;
1897   }
1898
1899   @Override /* BeanContextBuilder */
1900   public RestClientBuilder ignorePropertiesWithoutSetters(boolean value) {
1901      super.ignorePropertiesWithoutSetters(value);
1902      return this;
1903   }
1904
1905   @Override /* BeanContextBuilder */
1906   public RestClientBuilder ignoreInvocationExceptionsOnGetters(boolean value) {
1907      super.ignoreInvocationExceptionsOnGetters(value);
1908      return this;
1909   }
1910
1911   @Override /* BeanContextBuilder */
1912   public RestClientBuilder ignoreInvocationExceptionsOnGetters() {
1913      super.ignoreInvocationExceptionsOnGetters();
1914      return this;
1915   }
1916
1917   @Override /* BeanContextBuilder */
1918   public RestClientBuilder ignoreInvocationExceptionsOnSetters(boolean value) {
1919      super.ignoreInvocationExceptionsOnSetters(value);
1920      return this;
1921   }
1922
1923   @Override /* BeanContextBuilder */
1924   public RestClientBuilder ignoreInvocationExceptionsOnSetters() {
1925      super.ignoreInvocationExceptionsOnSetters();
1926      return this;
1927   }
1928
1929   @Override /* BeanContextBuilder */
1930   public RestClientBuilder sortProperties(boolean value) {
1931      super.sortProperties(value);
1932      return this;
1933   }
1934
1935   @Override /* BeanContextBuilder */
1936   public RestClientBuilder sortProperties() {
1937      super.sortProperties();
1938      return this;
1939   }
1940
1941   @Override /* BeanContextBuilder */
1942   public RestClientBuilder notBeanPackages(Object...values) {
1943      super.notBeanPackages(values);
1944      return this;
1945   }
1946
1947   @Override /* BeanContextBuilder */
1948   public RestClientBuilder notBeanPackages(String...values) {
1949      super.notBeanPackages(values);
1950      return this;
1951   }
1952
1953   @Override /* BeanContextBuilder */
1954   public RestClientBuilder notBeanPackages(boolean append, Object...values) {
1955      super.notBeanPackages(append, values);
1956      return this;
1957   }
1958
1959   @Override /* BeanContextBuilder */
1960   public RestClientBuilder notBeanPackagesRemove(Object...values) {
1961      super.notBeanPackagesRemove(values);
1962      return this;
1963   }
1964
1965   @Override /* BeanContextBuilder */
1966   public RestClientBuilder notBeanClasses(Object...values) {
1967      super.notBeanClasses(values);
1968      return this;
1969   }
1970
1971   @Override /* BeanContextBuilder */
1972   public RestClientBuilder notBeanClasses(Class<?>...values) {
1973      super.notBeanClasses(values);
1974      return this;
1975   }
1976
1977   @Override /* BeanContextBuilder */
1978   public RestClientBuilder notBeanClasses(boolean append, Object...values) {
1979      super.notBeanClasses(append, values);
1980      return this;
1981   }
1982
1983   @Override /* BeanContextBuilder */
1984   public RestClientBuilder notBeanClassesRemove(Object...values) {
1985      super.notBeanClassesRemove(values);
1986      return this;
1987   }
1988
1989   @Override /* BeanContextBuilder */
1990   public RestClientBuilder beanFilters(Object...values) {
1991      super.beanFilters(values);
1992      return this;
1993   }
1994
1995   @Override /* BeanContextBuilder */
1996   public RestClientBuilder beanFilters(Class<?>...values) {
1997      super.beanFilters(values);
1998      return this;
1999   }
2000
2001   @Override /* BeanContextBuilder */
2002   public RestClientBuilder beanFilters(boolean append, Object...values) {
2003      super.beanFilters(append, values);
2004      return this;
2005   }
2006
2007   @Override /* BeanContextBuilder */
2008   public RestClientBuilder beanFiltersRemove(Object...values) {
2009      super.beanFiltersRemove(values);
2010      return this;
2011   }
2012
2013   @Override /* BeanContextBuilder */
2014   public RestClientBuilder pojoSwaps(Object...values) {
2015      super.pojoSwaps(values);
2016      return this;
2017   }
2018
2019   @Override /* BeanContextBuilder */
2020   public RestClientBuilder pojoSwaps(Class<?>...values) {
2021      super.pojoSwaps(values);
2022      return this;
2023   }
2024
2025   @Override /* BeanContextBuilder */
2026   public RestClientBuilder pojoSwaps(boolean append, Object...values) {
2027      super.pojoSwaps(append, values);
2028      return this;
2029   }
2030
2031   @Override /* BeanContextBuilder */
2032   public RestClientBuilder pojoSwapsRemove(Object...values) {
2033      super.pojoSwapsRemove(values);
2034      return this;
2035   }
2036
2037   @Override /* BeanContextBuilder */
2038   public RestClientBuilder implClasses(Map<String,Class<?>> values) {
2039      super.implClasses(values);
2040      return this;
2041   }
2042
2043   @Override /* BeanContextBuilder */
2044   public <T> RestClientBuilder implClass(Class<T> interfaceClass, Class<? extends T> implClass) {
2045      super.implClass(interfaceClass, implClass);
2046      return this;
2047   }
2048
2049   @Override /* BeanContextBuilder */
2050   public RestClientBuilder beanDictionary(Object...values) {
2051      super.beanDictionary(values);
2052      return this;
2053   }
2054
2055   @Override /* BeanContextBuilder */
2056   public RestClientBuilder beanDictionary(Class<?>...values) {
2057      super.beanDictionary(values);
2058      return this;
2059   }
2060
2061   @Override /* BeanContextBuilder */
2062   public RestClientBuilder beanDictionary(boolean append, Object...values) {
2063      super.beanDictionary(append, values);
2064      return this;
2065   }
2066
2067   @Override /* BeanContextBuilder */
2068   public RestClientBuilder beanDictionaryRemove(Object...values) {
2069      super.beanDictionaryRemove(values);
2070      return this;
2071   }
2072
2073   @Override /* BeanContextBuilder */
2074   public RestClientBuilder beanTypePropertyName(String value) {
2075      super.beanTypePropertyName(value);
2076      return this;
2077   }
2078
2079   @Override /* BeanContextBuilder */
2080   public RestClientBuilder locale(Locale value) {
2081      super.locale(value);
2082      return this;
2083   }
2084
2085   @Override /* BeanContextBuilder */
2086   public RestClientBuilder timeZone(TimeZone value) {
2087      super.timeZone(value);
2088      return this;
2089   }
2090
2091   @Override /* BeanContextBuilder */
2092   public RestClientBuilder mediaType(MediaType value) {
2093      super.mediaType(value);
2094      return this;
2095   }
2096
2097   @Override /* BeanContextBuilder */
2098   public RestClientBuilder debug() {
2099      super.debug();
2100      set(RESTCLIENT_debug, true);
2101      header("Debug", true);
2102      return this;
2103   }
2104
2105   @Override /* ContextBuilder */
2106   public RestClientBuilder set(String name, Object value) {
2107      super.set(name, value);
2108      return this;
2109   }
2110
2111   @Override /* ContextBuilder */
2112   public RestClientBuilder set(boolean append, String name, Object value) {
2113      super.set(append, name, value);
2114      return this;
2115   }
2116
2117   @Override /* ContextBuilder */
2118   public RestClientBuilder set(Map<String,Object> properties) {
2119      super.set(properties);
2120      return this;
2121   }
2122
2123   @Override /* ContextBuilder */
2124   public RestClientBuilder add(Map<String,Object> properties) {
2125      super.add(properties);
2126      return this;
2127   }
2128
2129   @Override /* ContextBuilder */
2130   public RestClientBuilder addTo(String name, Object value) {
2131      super.addTo(name, value);
2132      return this;
2133   }
2134
2135   @Override /* ContextBuilder */
2136   public RestClientBuilder addTo(String name, String key, Object value) {
2137      super.addTo(name, key, value);
2138      return this;
2139   }
2140
2141   @Override /* ContextBuilder */
2142   public RestClientBuilder removeFrom(String name, Object value) {
2143      super.removeFrom(name, value);
2144      return this;
2145   }
2146
2147   @Override /* ContextBuilder */
2148   public RestClientBuilder apply(PropertyStore copyFrom) {
2149      super.apply(copyFrom);
2150      return this;
2151   }
2152
2153
2154   //------------------------------------------------------------------------------------------------
2155   // Passthrough methods for HttpClientBuilder.
2156   //------------------------------------------------------------------------------------------------
2157
2158   /**
2159    * @param redirectStrategy
2160    * @return This object (for method chaining).
2161    * @see HttpClientBuilder#setRedirectStrategy(RedirectStrategy)
2162    */
2163   public RestClientBuilder setRedirectStrategy(RedirectStrategy redirectStrategy) {
2164      httpClientBuilder.setRedirectStrategy(redirectStrategy);
2165      return this;
2166   }
2167
2168   /**
2169    * @param cookieSpecRegistry
2170    * @return This object (for method chaining).
2171    * @see HttpClientBuilder#setDefaultCookieSpecRegistry(Lookup)
2172    */
2173   public RestClientBuilder setDefaultCookieSpecRegistry(Lookup<CookieSpecProvider> cookieSpecRegistry) {
2174      httpClientBuilder.setDefaultCookieSpecRegistry(cookieSpecRegistry);
2175      return this;
2176   }
2177
2178   /**
2179    * @param requestExec
2180    * @return This object (for method chaining).
2181    * @see HttpClientBuilder#setRequestExecutor(HttpRequestExecutor)
2182    */
2183   public RestClientBuilder setRequestExecutor(HttpRequestExecutor requestExec) {
2184      httpClientBuilder.setRequestExecutor(requestExec);
2185      return this;
2186   }
2187
2188   /**
2189    * @param hostnameVerifier
2190    * @return This object (for method chaining).
2191    * @see HttpClientBuilder#setSSLHostnameVerifier(HostnameVerifier)
2192    */
2193   public RestClientBuilder setSSLHostnameVerifier(HostnameVerifier hostnameVerifier) {
2194      httpClientBuilder.setSSLHostnameVerifier(hostnameVerifier);
2195      return this;
2196   }
2197
2198   /**
2199    * @param publicSuffixMatcher
2200    * @return This object (for method chaining).
2201    * @see HttpClientBuilder#setPublicSuffixMatcher(PublicSuffixMatcher)
2202    */
2203   public RestClientBuilder setPublicSuffixMatcher(PublicSuffixMatcher publicSuffixMatcher) {
2204      httpClientBuilder.setPublicSuffixMatcher(publicSuffixMatcher);
2205      return this;
2206   }
2207
2208   /**
2209    * @param sslContext
2210    * @return This object (for method chaining).
2211    * @see HttpClientBuilder#setSSLContext(SSLContext)
2212    */
2213   public RestClientBuilder setSSLContext(SSLContext sslContext) {
2214      httpClientBuilder.setSSLContext(sslContext);
2215      return this;
2216   }
2217
2218   /**
2219    * @param sslSocketFactory
2220    * @return This object (for method chaining).
2221    * @see HttpClientBuilder#setSSLSocketFactory(LayeredConnectionSocketFactory)
2222    */
2223   public RestClientBuilder setSSLSocketFactory(LayeredConnectionSocketFactory sslSocketFactory) {
2224      httpClientBuilder.setSSLSocketFactory(sslSocketFactory);
2225      return this;
2226   }
2227
2228   /**
2229    * @param maxConnTotal
2230    * @return This object (for method chaining).
2231    * @see HttpClientBuilder#setMaxConnTotal(int)
2232    */
2233   public RestClientBuilder setMaxConnTotal(int maxConnTotal) {
2234      httpClientBuilder.setMaxConnTotal(maxConnTotal);
2235      return this;
2236   }
2237
2238   /**
2239    * @param maxConnPerRoute
2240    * @return This object (for method chaining).
2241    * @see HttpClientBuilder#setMaxConnPerRoute(int)
2242    */
2243   public RestClientBuilder setMaxConnPerRoute(int maxConnPerRoute) {
2244      httpClientBuilder.setMaxConnPerRoute(maxConnPerRoute);
2245      return this;
2246   }
2247
2248   /**
2249    * @param config
2250    * @return This object (for method chaining).
2251    * @see HttpClientBuilder#setDefaultSocketConfig(SocketConfig)
2252    */
2253   public RestClientBuilder setDefaultSocketConfig(SocketConfig config) {
2254      httpClientBuilder.setDefaultSocketConfig(config);
2255      return this;
2256   }
2257
2258   /**
2259    * @param config
2260    * @return This object (for method chaining).
2261    * @see HttpClientBuilder#setDefaultConnectionConfig(ConnectionConfig)
2262    */
2263   public RestClientBuilder setDefaultConnectionConfig(ConnectionConfig config) {
2264      httpClientBuilder.setDefaultConnectionConfig(config);
2265      return this;
2266   }
2267
2268   /**
2269    * @param connTimeToLive
2270    * @param connTimeToLiveTimeUnit
2271    * @return This object (for method chaining).
2272    * @see HttpClientBuilder#setConnectionTimeToLive(long,TimeUnit)
2273    */
2274   public RestClientBuilder setConnectionTimeToLive(long connTimeToLive, TimeUnit connTimeToLiveTimeUnit) {
2275      httpClientBuilder.setConnectionTimeToLive(connTimeToLive, connTimeToLiveTimeUnit);
2276      return this;
2277   }
2278
2279   /**
2280    * @param connManager
2281    * @return This object (for method chaining).
2282    * @see HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)
2283    */
2284   public RestClientBuilder setConnectionManager(HttpClientConnectionManager connManager) {
2285      this.httpClientConnectionManager = connManager;
2286      httpClientBuilder.setConnectionManager(connManager);
2287      return this;
2288   }
2289
2290   /**
2291    * @param shared
2292    * @return This object (for method chaining).
2293    * @see HttpClientBuilder#setConnectionManagerShared(boolean)
2294    */
2295   public RestClientBuilder setConnectionManagerShared(boolean shared) {
2296      httpClientBuilder.setConnectionManagerShared(shared);
2297      return this;
2298   }
2299
2300   /**
2301    * @param reuseStrategy
2302    * @return This object (for method chaining).
2303    * @see HttpClientBuilder#setConnectionReuseStrategy(ConnectionReuseStrategy)
2304    */
2305   public RestClientBuilder setConnectionReuseStrategy(ConnectionReuseStrategy reuseStrategy) {
2306      httpClientBuilder.setConnectionReuseStrategy(reuseStrategy);
2307      return this;
2308   }
2309
2310   /**
2311    * @param keepAliveStrategy
2312    * @return This object (for method chaining).
2313    * @see HttpClientBuilder#setKeepAliveStrategy(ConnectionKeepAliveStrategy)
2314    */
2315   public RestClientBuilder setKeepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy) {
2316      httpClientBuilder.setKeepAliveStrategy(keepAliveStrategy);
2317      return this;
2318   }
2319
2320   /**
2321    * @param targetAuthStrategy
2322    * @return This object (for method chaining).
2323    * @see HttpClientBuilder#setTargetAuthenticationStrategy(AuthenticationStrategy)
2324    */
2325   public RestClientBuilder setTargetAuthenticationStrategy(AuthenticationStrategy targetAuthStrategy) {
2326      httpClientBuilder.setTargetAuthenticationStrategy(targetAuthStrategy);
2327      return this;
2328   }
2329
2330   /**
2331    * @param proxyAuthStrategy
2332    * @return This object (for method chaining).
2333    * @see HttpClientBuilder#setProxyAuthenticationStrategy(AuthenticationStrategy)
2334    */
2335   public RestClientBuilder setProxyAuthenticationStrategy(AuthenticationStrategy proxyAuthStrategy) {
2336      httpClientBuilder.setProxyAuthenticationStrategy(proxyAuthStrategy);
2337      return this;
2338   }
2339
2340   /**
2341    * @param userTokenHandler
2342    * @return This object (for method chaining).
2343    * @see HttpClientBuilder#setUserTokenHandler(UserTokenHandler)
2344    */
2345   public RestClientBuilder setUserTokenHandler(UserTokenHandler userTokenHandler) {
2346      httpClientBuilder.setUserTokenHandler(userTokenHandler);
2347      return this;
2348   }
2349
2350   /**
2351    * @return This object (for method chaining).
2352    * @see HttpClientBuilder#disableConnectionState()
2353    */
2354   public RestClientBuilder disableConnectionState() {
2355      httpClientBuilder.disableConnectionState();
2356      return this;
2357   }
2358
2359   /**
2360    * @param schemePortResolver
2361    * @return This object (for method chaining).
2362    * @see HttpClientBuilder#setSchemePortResolver(SchemePortResolver)
2363    */
2364   public RestClientBuilder setSchemePortResolver(SchemePortResolver schemePortResolver) {
2365      httpClientBuilder.setSchemePortResolver(schemePortResolver);
2366      return this;
2367   }
2368
2369   /**
2370    * @param userAgent
2371    * @return This object (for method chaining).
2372    * @see HttpClientBuilder#setUserAgent(String)
2373    */
2374   public RestClientBuilder setUserAgent(String userAgent) {
2375      httpClientBuilder.setUserAgent(userAgent);
2376      return this;
2377   }
2378
2379   /**
2380    * @param defaultHeaders
2381    * @return This object (for method chaining).
2382    * @see HttpClientBuilder#setDefaultHeaders(Collection)
2383    */
2384   public RestClientBuilder setDefaultHeaders(Collection<? extends Header> defaultHeaders) {
2385      httpClientBuilder.setDefaultHeaders(defaultHeaders);
2386      return this;
2387   }
2388
2389   /**
2390    * @param itcp
2391    * @return This object (for method chaining).
2392    * @see HttpClientBuilder#addInterceptorFirst(HttpResponseInterceptor)
2393    */
2394   public RestClientBuilder addInterceptorFirst(HttpResponseInterceptor itcp) {
2395      httpClientBuilder.addInterceptorFirst(itcp);
2396      return this;
2397   }
2398
2399   /**
2400    * @param itcp
2401    * @return This object (for method chaining).
2402    * @see HttpClientBuilder#addInterceptorLast(HttpResponseInterceptor)
2403    */
2404   public RestClientBuilder addInterceptorLast(HttpResponseInterceptor itcp) {
2405      httpClientBuilder.addInterceptorLast(itcp);
2406      return this;
2407   }
2408
2409   /**
2410    * @param itcp
2411    * @return This object (for method chaining).
2412    * @see HttpClientBuilder#addInterceptorFirst(HttpRequestInterceptor)
2413    */
2414   public RestClientBuilder addInterceptorFirst(HttpRequestInterceptor itcp) {
2415      httpClientBuilder.addInterceptorFirst(itcp);
2416      return this;
2417   }
2418
2419   /**
2420    * @param itcp
2421    * @return This object (for method chaining).
2422    * @see HttpClientBuilder#addInterceptorLast(HttpRequestInterceptor)
2423    */
2424   public RestClientBuilder addInterceptorLast(HttpRequestInterceptor itcp) {
2425      httpClientBuilder.addInterceptorLast(itcp);
2426      return this;
2427   }
2428
2429   /**
2430    * @return This object (for method chaining).
2431    * @see HttpClientBuilder#disableCookieManagement()
2432    */
2433   public RestClientBuilder disableCookieManagement() {
2434      httpClientBuilder.disableCookieManagement();
2435      return this;
2436   }
2437
2438   /**
2439    * @return This object (for method chaining).
2440    * @see HttpClientBuilder#disableContentCompression()
2441    */
2442   public RestClientBuilder disableContentCompression() {
2443      httpClientBuilder.disableContentCompression();
2444      return this;
2445   }
2446
2447   /**
2448    * @return This object (for method chaining).
2449    * @see HttpClientBuilder#disableAuthCaching()
2450    */
2451   public RestClientBuilder disableAuthCaching() {
2452      httpClientBuilder.disableAuthCaching();
2453      return this;
2454   }
2455
2456   /**
2457    * @param httpprocessor
2458    * @return This object (for method chaining).
2459    * @see HttpClientBuilder#setHttpProcessor(HttpProcessor)
2460    */
2461   public RestClientBuilder setHttpProcessor(HttpProcessor httpprocessor) {
2462      httpClientBuilder.setHttpProcessor(httpprocessor);
2463      return this;
2464   }
2465
2466   /**
2467    * @param retryHandler
2468    * @return This object (for method chaining).
2469    * @see HttpClientBuilder#setRetryHandler(HttpRequestRetryHandler)
2470    */
2471   public RestClientBuilder setRetryHandler(HttpRequestRetryHandler retryHandler) {
2472      httpClientBuilder.setRetryHandler(retryHandler);
2473      return this;
2474   }
2475
2476   /**
2477    * @return This object (for method chaining).
2478    * @see HttpClientBuilder#disableAutomaticRetries()
2479    */
2480   public RestClientBuilder disableAutomaticRetries() {
2481      httpClientBuilder.disableAutomaticRetries();
2482      return this;
2483   }
2484
2485   /**
2486    * @param proxy
2487    * @return This object (for method chaining).
2488    * @see HttpClientBuilder#setProxy(HttpHost)
2489    */
2490   public RestClientBuilder setProxy(HttpHost proxy) {
2491      httpClientBuilder.setProxy(proxy);
2492      return this;
2493   }
2494
2495   /**
2496    * @param routePlanner
2497    * @return This object (for method chaining).
2498    * @see HttpClientBuilder#setRoutePlanner(HttpRoutePlanner)
2499    */
2500   public RestClientBuilder setRoutePlanner(HttpRoutePlanner routePlanner) {
2501      httpClientBuilder.setRoutePlanner(routePlanner);
2502      return this;
2503   }
2504
2505   /**
2506    * @return This object (for method chaining).
2507    * @see HttpClientBuilder#disableRedirectHandling()
2508    */
2509   public RestClientBuilder disableRedirectHandling() {
2510      httpClientBuilder.disableRedirectHandling();
2511      return this;
2512   }
2513
2514   /**
2515    * @param connectionBackoffStrategy
2516    * @return This object (for method chaining).
2517    * @see HttpClientBuilder#setConnectionBackoffStrategy(ConnectionBackoffStrategy)
2518    */
2519   public RestClientBuilder setConnectionBackoffStrategy(ConnectionBackoffStrategy connectionBackoffStrategy) {
2520      httpClientBuilder.setConnectionBackoffStrategy(connectionBackoffStrategy);
2521      return this;
2522   }
2523
2524   /**
2525    * @param backoffManager
2526    * @return This object (for method chaining).
2527    * @see HttpClientBuilder#setBackoffManager(BackoffManager)
2528    */
2529   public RestClientBuilder setBackoffManager(BackoffManager backoffManager) {
2530      httpClientBuilder.setBackoffManager(backoffManager);
2531      return this;
2532   }
2533
2534   /**
2535    * @param serviceUnavailStrategy
2536    * @return This object (for method chaining).
2537    * @see HttpClientBuilder#setServiceUnavailableRetryStrategy(ServiceUnavailableRetryStrategy)
2538    */
2539   public RestClientBuilder setServiceUnavailableRetryStrategy(ServiceUnavailableRetryStrategy serviceUnavailStrategy) {
2540      httpClientBuilder.setServiceUnavailableRetryStrategy(serviceUnavailStrategy);
2541      return this;
2542   }
2543
2544   /**
2545    * @param cookieStore
2546    * @return This object (for method chaining).
2547    * @see HttpClientBuilder#setDefaultCookieStore(CookieStore)
2548    */
2549   public RestClientBuilder setDefaultCookieStore(CookieStore cookieStore) {
2550      httpClientBuilder.setDefaultCookieStore(cookieStore);
2551      return this;
2552   }
2553
2554   /**
2555    * @param credentialsProvider
2556    * @return This object (for method chaining).
2557    * @see HttpClientBuilder#setDefaultCredentialsProvider(CredentialsProvider)
2558    */
2559   public RestClientBuilder setDefaultCredentialsProvider(CredentialsProvider credentialsProvider) {
2560      httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
2561      return this;
2562   }
2563
2564   /**
2565    * @param authSchemeRegistry
2566    * @return This object (for method chaining).
2567    * @see HttpClientBuilder#setDefaultAuthSchemeRegistry(Lookup)
2568    */
2569   public RestClientBuilder setDefaultAuthSchemeRegistry(Lookup<AuthSchemeProvider> authSchemeRegistry) {
2570      httpClientBuilder.setDefaultAuthSchemeRegistry(authSchemeRegistry);
2571      return this;
2572   }
2573
2574   /**
2575    * @param contentDecoderMap
2576    * @return This object (for method chaining).
2577    * @see HttpClientBuilder#setContentDecoderRegistry(Map)
2578    */
2579   public RestClientBuilder setContentDecoderRegistry(Map<String,InputStreamFactory> contentDecoderMap) {
2580      httpClientBuilder.setContentDecoderRegistry(contentDecoderMap);
2581      return this;
2582   }
2583
2584   /**
2585    * @param config
2586    * @return This object (for method chaining).
2587    * @see HttpClientBuilder#setDefaultRequestConfig(RequestConfig)
2588    */
2589   public RestClientBuilder setDefaultRequestConfig(RequestConfig config) {
2590      httpClientBuilder.setDefaultRequestConfig(config);
2591      return this;
2592   }
2593
2594   /**
2595    * @return This object (for method chaining).
2596    * @see HttpClientBuilder#useSystemProperties()
2597    */
2598   public RestClientBuilder useSystemProperties() {
2599      httpClientBuilder.useSystemProperties();
2600      return this;
2601   }
2602
2603   /**
2604    * @return This object (for method chaining).
2605    * @see HttpClientBuilder#evictExpiredConnections()
2606    */
2607   public RestClientBuilder evictExpiredConnections() {
2608      httpClientBuilder.evictExpiredConnections();
2609      return this;
2610   }
2611
2612   /**
2613    * @param maxIdleTime
2614    * @param maxIdleTimeUnit
2615    * @return This object (for method chaining).
2616    * @see HttpClientBuilder#evictIdleConnections(long,TimeUnit)
2617    */
2618   public RestClientBuilder evictIdleConnections(long maxIdleTime, TimeUnit maxIdleTimeUnit) {
2619      httpClientBuilder.evictIdleConnections(maxIdleTime, maxIdleTimeUnit);
2620      return this;
2621   }
2622}