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.InputStreamParser.*;
017import static org.apache.juneau.parser.ReaderParser.*;
018import static org.apache.juneau.rest.client.RestClient.*;
019import static org.apache.juneau.BeanTraverseContext.*;
020import static org.apache.juneau.serializer.OutputStreamSerializer.*;
021import static org.apache.juneau.serializer.WriterSerializer.*;
022import static org.apache.juneau.uon.UonSerializer.*;
023
024import java.lang.annotation.*;
025import java.lang.reflect.*;
026import java.net.*;
027import java.net.URI;
028import java.security.*;
029import java.util.*;
030import java.util.concurrent.*;
031import java.util.logging.*;
032
033import javax.net.ssl.*;
034
035import org.apache.http.*;
036import org.apache.http.auth.*;
037import org.apache.http.client.*;
038import org.apache.http.client.CookieStore;
039import org.apache.http.client.config.*;
040import org.apache.http.client.entity.*;
041import org.apache.http.config.*;
042import org.apache.http.conn.*;
043import org.apache.http.conn.routing.*;
044import org.apache.http.conn.socket.*;
045import org.apache.http.conn.ssl.*;
046import org.apache.http.conn.util.*;
047import org.apache.http.cookie.*;
048import org.apache.http.impl.client.*;
049import org.apache.http.impl.conn.*;
050import org.apache.http.protocol.*;
051import org.apache.juneau.*;
052import org.apache.juneau.html.*;
053import org.apache.juneau.http.*;
054import org.apache.juneau.httppart.*;
055import org.apache.juneau.internal.*;
056import org.apache.juneau.json.*;
057import org.apache.juneau.marshall.*;
058import org.apache.juneau.msgpack.*;
059import org.apache.juneau.oapi.*;
060import org.apache.juneau.parser.*;
061import org.apache.juneau.plaintext.*;
062import org.apache.juneau.reflect.*;
063import org.apache.juneau.serializer.*;
064import org.apache.juneau.svl.*;
065import org.apache.juneau.uon.*;
066import org.apache.juneau.urlencoding.*;
067import org.apache.juneau.xml.*;
068
069/**
070 * Builder class for the {@link RestClient} class.
071 *
072 * <p>
073 * Instances of this class are created by the following methods:
074 * <ul>
075 *    <li>{@link RestClient#create()} - Create from scratch.
076 *    <li>{@link RestClient#create(Serializer,Parser)} - Create from scratch using specified serializer/parser.
077 *    <li>{@link RestClient#create(Class,Class)} - Create from scratch using specified serializer/parser classes.
078 *    <li>{@link RestClient#builder()} - Copy settings from an existing client.
079 * </ul>
080 *
081 * <ul class='seealso'>
082 *    <li class='link'>{@doc juneau-rest-client}
083 * </ul>
084 */
085public class RestClientBuilder extends BeanContextBuilder {
086
087   private HttpClientBuilder httpClientBuilder;
088   private CloseableHttpClient httpClient;
089
090   // Deprecated
091   @Deprecated private HttpClientConnectionManager httpClientConnectionManager;
092   @Deprecated private boolean enableSsl = false;
093   @Deprecated private HostnameVerifier hostnameVerifier;
094   @Deprecated private KeyManager[] keyManagers;
095   @Deprecated private TrustManager[] trustManagers;
096   @Deprecated private SecureRandom secureRandom;
097   @Deprecated private String[] sslProtocols, cipherSuites;
098   @Deprecated private boolean pooled;
099
100   /**
101    * Constructor.
102    * @param ps
103    *    Initial configuration properties for this builder.
104    *    <br>Can be <jk>null</jk>.
105    * @param httpClientBuilder
106    *    The HTTP client builder to use for this REST client builder.
107    *    <br>Can be <jk>null</jk> to just call {@link #createHttpClientBuilder()} to instantiate it again.
108    */
109   protected RestClientBuilder(PropertyStore ps, HttpClientBuilder httpClientBuilder) {
110      super(ps);
111      this.httpClientBuilder = httpClientBuilder != null ? httpClientBuilder : createHttpClientBuilder();
112   }
113
114   @Override /* ContextBuilder */
115   public RestClient build() {
116      return new RestClient(this);
117   }
118
119   //------------------------------------------------------------------------------------------------------------------
120   // Convenience marshalling support methods.
121   //------------------------------------------------------------------------------------------------------------------
122
123   /**
124    * Convenience method for specifying JSON as the transmission media type.
125    *
126    * <p>
127    * Identical to calling <code>serializer(JsonSerializer.<jk>class</jk>).parser(JsonParser.<jk>class</jk>)</code>.
128    *
129    * @return This object (for method chaining).
130    */
131   public RestClientBuilder json() {
132      return serializer(JsonSerializer.class).parser(JsonParser.class);
133   }
134
135   /**
136    * Convenience method for specifying Simple JSON as the transmission media type.
137    *
138    * <p>
139    * Identical to calling <code>serializer(SimpleJsonSerializer.<jk>class</jk>).parser(JsonParser.<jk>class</jk>)</code>.
140    *
141    * @return This object (for method chaining).
142    */
143   public RestClientBuilder simpleJson() {
144      return serializer(SimpleJsonSerializer.class).parser(JsonParser.class);
145   }
146
147   /**
148    * Convenience method for specifying XML as the transmission media type.
149    *
150    * <p>
151    * Identical to calling <code>serializer(XmlSerializer.<jk>class</jk>).parser(XmlParser.<jk>class</jk>)</code>.
152    *
153    * @return This object (for method chaining).
154    */
155   public RestClientBuilder xml() {
156      return serializer(XmlSerializer.class).parser(XmlParser.class);
157   }
158
159   /**
160    * Convenience method for specifying HTML as the transmission media type.
161    *
162    * <p>
163    * Identical to calling <code>serializer(HtmlSerializer.<jk>class</jk>).parser(HtmlParser.<jk>class</jk>)</code>.
164    *
165    * @return This object (for method chaining).
166    */
167   public RestClientBuilder html() {
168      return serializer(HtmlSerializer.class).parser(HtmlParser.class);
169   }
170
171   /**
172    * Convenience method for specifying plain-text as the transmission media type.
173    *
174    * <p>
175    * Identical to calling <code>serializer(PlainTextSerializer.<jk>class</jk>).parser(PlainTextParser.<jk>class</jk>)</code>.
176    *
177    * @return This object (for method chaining).
178    */
179   public RestClientBuilder plainText() {
180      return serializer(PlainTextSerializer.class).parser(PlainTextParser.class);
181   }
182
183   /**
184    * Convenience method for specifying MessagePack as the transmission media type.
185    *
186    * <p>
187    * Identical to calling <code>serializer(MsgPackSerializer.<jk>class</jk>).parser(MsgPackParser.<jk>class</jk>)</code>.
188    *
189    * @return This object (for method chaining).
190    */
191   public RestClientBuilder msgpack() {
192      return serializer(MsgPackSerializer.class).parser(MsgPackParser.class);
193   }
194
195   /**
196    * Convenience method for specifying UON as the transmission media type.
197    *
198    * <p>
199    * Identical to calling <code>serializer(UonSerializer.<jk>class</jk>).parser(UonParser.<jk>class</jk>)</code>.
200    *
201    * @return This object (for method chaining).
202    */
203   public RestClientBuilder uon() {
204      return serializer(UonSerializer.class).parser(UonParser.class);
205   }
206
207   /**
208    * Convenience method for specifying URL-Encoding as the transmission media type.
209    *
210    * <p>
211    * Identical to calling <code>serializer(UrlEncodingSerializer.<jk>class</jk>).parser(UrlEncodingParser.<jk>class</jk>)</code>.
212    *
213    * @return This object (for method chaining).
214    */
215   public RestClientBuilder urlEnc() {
216      return serializer(UrlEncodingSerializer.class).parser(UrlEncodingParser.class);
217   }
218
219   /**
220    * Convenience method for specifying URL-Encoding as the transmission media type.
221    *
222    * <p>
223    * Identical to calling <code>serializer(OpenApiSerializer.<jk>class</jk>).parser(OpenApiParser.<jk>class</jk>)</code>.
224    *
225    * @return This object (for method chaining).
226    */
227   public RestClientBuilder openapi() {
228      return serializer(OpenApiSerializer.class).parser(OpenApiParser.class);
229   }
230
231   //------------------------------------------------------------------------------------------------------------------
232   // HttpClientBuilder
233   //------------------------------------------------------------------------------------------------------------------
234
235   /**
236    * Creates an instance of an {@link HttpClientBuilder} to be used to create the {@link HttpClient}.
237    *
238    * <p>
239    * Subclasses can override this method to provide their own client builder.
240    * The builder can also be specified using the {@link #httpClientBuilder(HttpClientBuilder)} method.
241    *
242    * <p>
243    * The predefined method returns an {@link HttpClientBuilder} with the following settings:
244    * <ul>
245    *    <li>Lax redirect strategy.
246    * </ul>
247    *
248    * @return The HTTP client builder to use to create the HTTP client.
249    */
250   protected HttpClientBuilder createHttpClientBuilder() {
251      return HttpClientBuilder.create().setRedirectStrategy(new AllowAllRedirects());
252   }
253
254   /**
255    * Returns the {@link HttpClientBuilder} that will be used to create the {@link HttpClient} used by {@link RestClient}.
256    *
257    * <p>
258    * This method can be used to make customizations to the {@link HttpClient}.
259    *
260    * <p>
261    * If not set via {@link #httpClientBuilder(HttpClientBuilder)}, then this object is the one created by {@link #createHttpClientBuilder()}.
262    *
263    * @return The {@link HttpClientBuilder} that will be used to create the {@link HttpClient} used by {@link RestClient}.
264    */
265   public HttpClientBuilder getHttpClientBuilder() {
266      if (httpClientBuilder == null)
267         httpClientBuilder = createHttpClientBuilder();
268      return httpClientBuilder;
269   }
270
271   /**
272    * Sets the {@link HttpClientBuilder} that will be used to create the {@link HttpClient} used by {@link RestClient}.
273    *
274    * <p>
275    * This can be used to bypass the builder created by {@link #createHttpClientBuilder()} method.
276    *
277    * @param value The {@link HttpClientBuilder} that will be used to create the {@link HttpClient} used by {@link RestClient}.
278    * @return This object (for method chaining).
279    */
280   public RestClientBuilder httpClientBuilder(HttpClientBuilder value) {
281      this.httpClientBuilder = value;
282      return this;
283   }
284
285   //------------------------------------------------------------------------------------------------------------------
286   // HttpClient
287   //------------------------------------------------------------------------------------------------------------------
288
289   /**
290    * Creates an instance of an {@link HttpClient} to be used to handle all HTTP communications with the target server.
291    *
292    * <p>
293    * This HTTP client is used when the HTTP client is not specified through one of the constructors or the
294    * {@link #httpClient(CloseableHttpClient, boolean)} method.
295    *
296    * <p>
297    * Subclasses can override this method to provide specially-configured HTTP clients to handle stuff such as
298    * SSL/TLS certificate handling, authentication, etc.
299    *
300    * <p>
301    * The default implementation returns an instance of {@link HttpClient} using the client builder returned by
302    * {@link #createHttpClientBuilder()}.
303    *
304    * @return The HTTP client to use.
305    * @throws Exception Error occurred.
306    */
307   protected CloseableHttpClient createHttpClient() throws Exception {
308      // Don't call createConnectionManager() if RestClient.setConnectionManager() was called.
309      if (httpClientConnectionManager == null)
310         httpClientBuilder.setConnectionManager(createConnectionManager());
311      else
312         httpClientBuilder.setConnectionManager(httpClientConnectionManager);
313      return httpClientBuilder.build();
314   }
315
316   /**
317    * Returns the {@link HttpClient} to be used to handle all HTTP communications with the target server.
318    *
319    * @return The {@link HttpClient} to be used to handle all HTTP communications with the target server.
320    */
321   public CloseableHttpClient getHttpClient() {
322      try {
323         return httpClient != null ? httpClient : createHttpClient();
324      } catch (Exception e) {
325         throw new RuntimeException(e);
326      }
327   }
328
329   /**
330    * Sets the {@link HttpClient} to be used to handle all HTTP communications with the target server.
331    *
332    * <p>
333    * This can be used to bypass the client created by {@link #createHttpClient()} method.
334    *
335    * @param value The {@link HttpClient} to be used to handle all HTTP communications with the target server.
336    * @return This object (for method chaining).
337    */
338   public RestClientBuilder httpClient(CloseableHttpClient value) {
339      this.httpClient = value;
340      return this;
341   }
342
343   /**
344    * Sets the internal {@link HttpClient} to use for handling HTTP communications.
345    *
346    * <div class='warn'>
347    *    <b>Deprecated</b> - Use {@link #httpClient(CloseableHttpClient)} and {@link #keepHttpClientOpen(boolean)}
348    * </div>
349    *
350    * @param httpClient The HTTP client.
351    * @param keepHttpClientOpen Don't close this client when the {@link RestClient#close()} method is called.
352    * @return This object (for method chaining).
353    */
354   @Deprecated
355   public RestClientBuilder httpClient(CloseableHttpClient httpClient, boolean keepHttpClientOpen) {
356      this.httpClient = httpClient;
357      set(RESTCLIENT_keepHttpClientOpen, keepHttpClientOpen);
358      return this;
359   }
360
361   //------------------------------------------------------------------------------------------------------------------
362   // Logging.
363   //------------------------------------------------------------------------------------------------------------------
364
365   /**
366    * Adds a {@link RestCallLogger} to the list of interceptors on this class.
367    *
368    * @param level The log level to log messages at.
369    * @param log The logger to log messages to.
370    * @return This object (for method chaining).
371    */
372   public RestClientBuilder logTo(Level level, Logger log) {
373      return interceptors(new RestCallLogger(level, log));
374   }
375
376   /**
377    * Sets the internal {@link HttpClientConnectionManager}.
378    *
379    * @param httpClientConnectionManager The HTTP client connection manager.
380    * @return This object (for method chaining).
381    */
382   public RestClientBuilder httpClientConnectionManager(HttpClientConnectionManager httpClientConnectionManager) {
383      this.httpClientConnectionManager = httpClientConnectionManager;
384      return this;
385   }
386
387   //------------------------------------------------------------------------------------------------------------------
388   // Deprecated HttpClientBuilder methods.
389   //------------------------------------------------------------------------------------------------------------------
390
391   /**
392    * Creates the {@link HttpClientConnectionManager} returned by {@link #createConnectionManager()}.
393    *
394    * <div class='warn'>
395    *    <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)}
396    * </div>
397    *
398    * <p>
399    * Subclasses can override this method to provide their own connection manager.
400    *
401    * <p>
402    * The default implementation returns an instance of a {@link PoolingHttpClientConnectionManager}.
403    *
404    * @return The HTTP client builder to use to create the HTTP client.
405    * @throws NoSuchAlgorithmException Unknown cryptographic algorithm.
406    * @throws KeyManagementException General key management exception.
407    */
408   @SuppressWarnings("resource")
409   @Deprecated
410   protected HttpClientConnectionManager createConnectionManager() throws KeyManagementException, NoSuchAlgorithmException {
411      if (enableSsl) {
412
413         HostnameVerifier hv = hostnameVerifier != null ? hostnameVerifier : new DefaultHostnameVerifier();
414         TrustManager[] tm = trustManagers;
415         String[] sslp = sslProtocols == null ? getDefaultProtocols() : sslProtocols;
416         SecureRandom sr = secureRandom;
417         KeyManager[] km = keyManagers;
418         String[] cs = cipherSuites;
419
420         RegistryBuilder<ConnectionSocketFactory> rb = RegistryBuilder.<ConnectionSocketFactory>create();
421         rb.register("http", PlainConnectionSocketFactory.getSocketFactory());
422
423         SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom().build();
424         sslContext.init(km, tm, sr);
425
426         SSLConnectionSocketFactory sslcsf = new SSLConnectionSocketFactory(sslContext, sslp, cs, hv);
427         rb.register("https", sslcsf).build();
428
429         return (pooled ? new PoolingHttpClientConnectionManager(rb.build()) : new BasicHttpClientConnectionManager(rb.build()));
430      }
431
432      // Using pooling connection so that this client is threadsafe.
433      return (pooled ? new PoolingHttpClientConnectionManager() : new BasicHttpClientConnectionManager());
434   }
435
436   private static String[] getDefaultProtocols() {
437      String sp = System.getProperty("transport.client.protocol");
438      if (isEmpty(sp))
439         return new String[] {"SSL_TLS","TLS","SSL"};
440      return StringUtils.split(sp, ',');
441   }
442
443   /**
444    * Enable SSL support on this client.
445    *
446    * <div class='warn'>
447    *    <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)}
448    * </div>
449    *
450    * <p>
451    * Used in conjunction with the following methods for setting up SSL parameters:
452    * <ul class='javatree'>
453    *    <li class='jf'>{@link #sslProtocols(String...)}
454    *    <li class='jf'>{@link #cipherSuites(String...)}
455    *    <li class='jf'>{@link #hostnameVerifier(HostnameVerifier)}
456    *    <li class='jf'>{@link #keyManagers(KeyManager...)}
457    *    <li class='jf'>{@link #trustManagers(TrustManager...)}
458    *    <li class='jf'>{@link #secureRandom(SecureRandom)}
459    * </ul>
460    *
461    * @return This object (for method chaining).
462    */
463   @Deprecated
464   public RestClientBuilder enableSSL() {
465      this.enableSsl = true;
466      return this;
467   }
468
469   /**
470    * Enable LARestClientBuilder SSL support.
471    *
472    * <div class='warn'>
473    *    <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)}
474    * </div>
475    *
476    * <p>
477    * Same as calling the following:
478    * <p class='bcode w800'>
479    *    builder
480    *       .enableSSL()
481    *       .hostnameVerifier(<jk>new</jk> NoopHostnameVerifier())
482    *       .trustManagers(<jk>new</jk> SimpleX509TrustManager(<jk>true</jk>));
483    * </p>
484    *
485    * @return This object (for method chaining).
486    * @throws KeyStoreException Generic keystore exception.
487    * @throws NoSuchAlgorithmException Unknown cryptographic algorithm.
488    */
489   @Deprecated
490   public RestClientBuilder enableLaxSSL() throws KeyStoreException, NoSuchAlgorithmException {
491      this.enableSsl = true;
492      hostnameVerifier(new NoopHostnameVerifier());
493      trustManagers(new SimpleX509TrustManager(true));
494      return this;
495   }
496
497   /**
498    * Supported SSL protocols.
499    *
500    * <div class='warn'>
501    *    <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)}
502    * </div>
503    *
504    * <p>
505    * This is the value passed to the <c>supportedProtocols</c> parameter of the
506    * {@link SSLConnectionSocketFactory#SSLConnectionSocketFactory(SSLContext,String[],String[],HostnameVerifier)}
507    * constructor.
508    *
509    * <p>
510    * The default value is taken from the system property <js>"transport.client.protocol"</js>.
511    * <br>If system property is not defined, defaults to <code>{<js>"SSL_TLS"</js>,<js>"TLS"</js>,<js>"SSL"</js>}</code>.
512    *
513    * <p>
514    * This method is effectively ignored if {@link #enableSSL()} has not been called or the client connection manager
515    * has been defined via {@link #httpClientConnectionManager(HttpClientConnectionManager)}.
516    *
517    * @param sslProtocols The supported SSL protocols.
518    * @return This object (for method chaining).
519    */
520   @Deprecated
521   public RestClientBuilder sslProtocols(String...sslProtocols) {
522      this.sslProtocols = sslProtocols;
523      return this;
524   }
525
526   /**
527    * Supported cipher suites.
528    *
529    * <div class='warn'>
530    *    <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)}
531    * </div>
532    *
533    * <p>
534    * This is the value passed to the <c>supportedCipherSuites</c> parameter of the
535    * {@link SSLConnectionSocketFactory#SSLConnectionSocketFactory(SSLContext,String[],String[],HostnameVerifier)}
536    * constructor.
537    *
538    * <p>
539    * The default value is <jk>null</jk>.
540    *
541    * <p>
542    * This method is effectively ignored if {@link #enableSSL()} has not been called or the client connection manager
543    * has been defined via {@link #httpClientConnectionManager(HttpClientConnectionManager)}.
544    *
545    * @param cipherSuites The supported cipher suites.
546    * @return This object (for method chaining).
547    */
548   @Deprecated
549   public RestClientBuilder cipherSuites(String...cipherSuites) {
550      this.cipherSuites = cipherSuites;
551      return this;
552   }
553
554   /**
555    * Hostname verifier.
556    *
557    * <div class='warn'>
558    *    <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)}
559    * </div>
560    *
561    * <p>
562    * This is the value passed to the <c>hostnameVerifier</c> parameter of the
563    * {@link SSLConnectionSocketFactory#SSLConnectionSocketFactory(SSLContext,String[],String[],HostnameVerifier)}
564    * constructor.
565    *
566    * <p>
567    * The default value is <jk>null</jk>.
568    *
569    * <p>
570    * This method is effectively ignored if {@link #enableSSL()} has not been called or the client connection manager
571    * has been defined via {@link #httpClientConnectionManager(HttpClientConnectionManager)}.
572    *
573    * @param hostnameVerifier The hostname verifier.
574    * @return This object (for method chaining).
575    */
576   @Deprecated
577   public RestClientBuilder hostnameVerifier(HostnameVerifier hostnameVerifier) {
578      this.hostnameVerifier = hostnameVerifier;
579      return this;
580   }
581
582   /**
583    * Key managers.
584    *
585    * <div class='warn'>
586    *    <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)}
587    * </div>
588    *
589    * <p>
590    * This is the value passed to the <c>keyManagers</c> parameter of the
591    * {@link SSLContext#init(KeyManager[],TrustManager[],SecureRandom)} method.
592    *
593    * <p>
594    * The default value is <jk>null</jk>.
595    *
596    * <p>
597    * This method is effectively ignored if {@link #enableSSL()} has not been called or the client connection manager
598    * has been defined via {@link #httpClientConnectionManager(HttpClientConnectionManager)}.
599    *
600    * @param keyManagers The key managers.
601    * @return This object (for method chaining).
602    */
603   @Deprecated
604   public RestClientBuilder keyManagers(KeyManager...keyManagers) {
605      this.keyManagers = keyManagers;
606      return this;
607   }
608
609   /**
610    * Trust managers.
611    *
612    * <div class='warn'>
613    *    <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)}
614    * </div>
615    *
616    * <p>
617    * This is the value passed to the <c>trustManagers</c> parameter of the
618    * {@link SSLContext#init(KeyManager[],TrustManager[],SecureRandom)} method.
619    *
620    * <p>
621    * The default value is <jk>null</jk>.
622    *
623    * <p>
624    * This method is effectively ignored if {@link #enableSSL()} has not been called or the client connection manager
625    * has been defined via {@link #httpClientConnectionManager(HttpClientConnectionManager)}.
626    *
627    * @param trustManagers The trust managers.
628    * @return This object (for method chaining).
629    */
630   @Deprecated
631   public RestClientBuilder trustManagers(TrustManager...trustManagers) {
632      this.trustManagers = trustManagers;
633      return this;
634   }
635
636   /**
637    * Trust managers.
638    *
639    * <div class='warn'>
640    *    <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)}
641    * </div>
642    *
643    * <p>
644    * This is the value passed to the <c>random</c> parameter of the
645    * {@link SSLContext#init(KeyManager[],TrustManager[],SecureRandom)} method.
646    *
647    * <p>
648    * The default value is <jk>null</jk>.
649    *
650    * <p>
651    * This method is effectively ignored if {@link #enableSSL()} has not been called or the client connection manager
652    * has been defined via {@link #httpClientConnectionManager(HttpClientConnectionManager)}.
653    *
654    * @param secureRandom The random number generator.
655    * @return This object (for method chaining).
656    */
657   @Deprecated
658   public RestClientBuilder secureRandom(SecureRandom secureRandom) {
659      this.secureRandom = secureRandom;
660      return this;
661   }
662
663   /**
664    * When called, the {@link #createConnectionManager()} method will return a {@link PoolingHttpClientConnectionManager}
665    * instead of a {@link BasicHttpClientConnectionManager}.
666    *
667    * <div class='warn'>
668    *    <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)}
669    * </div>
670    *
671    * @return This object (for method chaining).
672    */
673   @Deprecated
674   public RestClientBuilder pooled() {
675      this.pooled = true;
676      return this;
677   }
678
679   /**
680    * Set up this client to use BASIC auth.
681    *
682    * <div class='warn'>
683    *    <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)}
684    * </div>
685    *
686    * @param host The auth scope hostname.
687    * @param port The auth scope port.
688    * @param user The username.
689    * @param pw The password.
690    * @return This object (for method chaining).
691    */
692   @Deprecated
693   public RestClientBuilder basicAuth(String host, int port, String user, String pw) {
694      AuthScope scope = new AuthScope(host, port);
695      Credentials up = new UsernamePasswordCredentials(user, pw);
696      CredentialsProvider p = new BasicCredentialsProvider();
697      p.setCredentials(scope, up);
698      defaultCredentialsProvider(p);
699      return this;
700   }
701
702   //-----------------------------------------------------------------------------------------------------------------
703   // HTTP headers
704   //-----------------------------------------------------------------------------------------------------------------
705
706   /**
707    * Sets arbitrary request headers.
708    *
709    * @param headers The headers to set on requests.
710    * @return This object (for method chaining).
711    */
712   public RestClientBuilder headers(Map<String,Object> headers) {
713      if (headers != null)
714         for (Map.Entry<String,Object> e : headers.entrySet())
715            header(e.getKey(), e.getValue());
716      return this;
717   }
718
719   /**
720    * Sets the value for the <c>Accept</c> request header.
721    *
722    * <p>
723    * This overrides the media type specified on the parser, but is overridden by calling
724    * <code>header(<js>"Accept"</js>, value);</code>
725    *
726    * @param value The new header value.
727    * @return This object (for method chaining).
728    */
729   public RestClientBuilder accept(Object value) {
730      return header("Accept", value);
731   }
732
733   /**
734    * Sets the value for the <c>Accept-Charset</c> request header.
735    *
736    * <p>
737    * This is a shortcut for calling <code>header(<js>"Accept-Charset"</js>, value);</code>
738    *
739    * @param value The new header value.
740    * @return This object (for method chaining).
741    */
742   public RestClientBuilder acceptCharset(Object value) {
743      return header("Accept-Charset", value);
744   }
745
746   /**
747    * Sets the value for the <c>Accept-Encoding</c> request header.
748    *
749    * <p>
750    * This is a shortcut for calling <code>header(<js>"Accept-Encoding"</js>, value);</code>
751    *
752    * @param value The new header value.
753    * @return This object (for method chaining).
754    */
755   public RestClientBuilder acceptEncoding(Object value) {
756      return header("Accept-Encoding", value);
757   }
758
759   /**
760    * Sets the value for the <c>Accept-Language</c> request header.
761    *
762    * <p>
763    * This is a shortcut for calling <code>header(<js>"Accept-Language"</js>, value);</code>
764    *
765    * @param value The new header value.
766    * @return This object (for method chaining).
767    */
768   public RestClientBuilder acceptLanguage(Object value) {
769      return header("Accept-Language", value);
770   }
771
772   /**
773    * Sets the value for the <c>Authorization</c> request header.
774    *
775    * <p>
776    * This is a shortcut for calling <code>header(<js>"Authorization"</js>, value);</code>
777    *
778    * @param value The new header value.
779    * @return This object (for method chaining).
780    */
781   public RestClientBuilder authorization(Object value) {
782      return header("Authorization", value);
783   }
784
785   /**
786    * Sets the value for the <c>Cache-Control</c> request header.
787    *
788    * <p>
789    * This is a shortcut for calling <code>header(<js>"Cache-Control"</js>, value);</code>
790    *
791    * @param value The new header value.
792    * @return This object (for method chaining).
793    */
794   public RestClientBuilder cacheControl(Object value) {
795      return header("Cache-Control", value);
796   }
797
798   /**
799    * Sets the client version by setting the value for the <js>"X-Client-Version"</js> header.
800    *
801    * @param version The version string (e.g. <js>"1.2.3"</js>)
802    * @return This object (for method chaining).
803    */
804   public RestClientBuilder clientVersion(String version) {
805      return header("X-Client-Version", version);
806   }
807
808   /**
809    * Sets the value for the <c>Connection</c> request header.
810    *
811    * <p>
812    * This is a shortcut for calling <code>header(<js>"Connection"</js>, value);</code>
813    *
814    * @param value The new header value.
815    * @return This object (for method chaining).
816    */
817   public RestClientBuilder connection(Object value) {
818      return header("Connection", value);
819   }
820
821   /**
822    * Sets the value for the <c>Content-Length</c> request header.
823    *
824    * <p>
825    * This is a shortcut for calling <code>header(<js>"Content-Length"</js>, value);</code>
826    *
827    * @param value The new header value.
828    * @return This object (for method chaining).
829    */
830   public RestClientBuilder contentLength(Object value) {
831      return header("Content-Length", value);
832   }
833
834   /**
835    * Sets the value for the <c>Content-Type</c> request header.
836    *
837    * <p>
838    * This overrides the media type specified on the serializer, but is overridden by calling
839    * <code>header(<js>"Content-Type"</js>, value);</code>
840    *
841    * @param value The new header value.
842    * @return This object (for method chaining).
843    */
844   public RestClientBuilder contentType(Object value) {
845      return header("Content-Type", value);
846   }
847
848   /**
849    * Sets the value for the <c>Date</c> request header.
850    *
851    * <p>
852    * This is a shortcut for calling <code>header(<js>"Date"</js>, value);</code>
853    *
854    * @param value The new header value.
855    * @return This object (for method chaining).
856    */
857   public RestClientBuilder date(Object value) {
858      return header("Date", value);
859   }
860
861   /**
862    * Sets the value for the <c>Expect</c> request header.
863    *
864    * <p>
865    * This is a shortcut for calling <code>header(<js>"Expect"</js>, value);</code>
866    *
867    * @param value The new header value.
868    * @return This object (for method chaining).
869    */
870   public RestClientBuilder expect(Object value) {
871      return header("Expect", value);
872   }
873
874   /**
875    * Sets the value for the <c>Forwarded</c> request header.
876    *
877    * <p>
878    * This is a shortcut for calling <code>header(<js>"Forwarded"</js>, value);</code>
879    *
880    * @param value The new header value.
881    * @return This object (for method chaining).
882    */
883   public RestClientBuilder forwarded(Object value) {
884      return header("Forwarded", value);
885   }
886
887   /**
888    * Sets the value for the <c>From</c> request header.
889    *
890    * <p>
891    * This is a shortcut for calling <code>header(<js>"From"</js>, value);</code>
892    *
893    * @param value The new header value.
894    * @return This object (for method chaining).
895    */
896   public RestClientBuilder from(Object value) {
897      return header("From", value);
898   }
899
900   /**
901    * Sets the value for the <c>Host</c> request header.
902    *
903    * <p>
904    * This is a shortcut for calling <code>header(<js>"Host"</js>, value);</code>
905    *
906    * @param value The new header value.
907    * @return This object (for method chaining).
908    */
909   public RestClientBuilder host(Object value) {
910      return header("Host", value);
911   }
912
913   /**
914    * Sets the value for the <c>If-Match</c> request header.
915    *
916    * <p>
917    * This is a shortcut for calling <code>header(<js>"If-Match"</js>, value);</code>
918    *
919    * @param value The new header value.
920    * @return This object (for method chaining).
921    */
922   public RestClientBuilder ifMatch(Object value) {
923      return header("If-Match", value);
924   }
925
926   /**
927    * Sets the value for the <c>If-Modified-Since</c> request header.
928    *
929    * <p>
930    * This is a shortcut for calling <code>header(<js>"If-Modified-Since"</js>, value);</code>
931    *
932    * @param value The new header value.
933    * @return This object (for method chaining).
934    */
935   public RestClientBuilder ifModifiedSince(Object value) {
936      return header("If-Modified-Since", value);
937   }
938
939   /**
940    * Sets the value for the <c>If-None-Match</c> request header.
941    *
942    * <p>
943    * This is a shortcut for calling <code>header(<js>"If-None-Match"</js>, value);</code>
944    *
945    * @param value The new header value.
946    * @return This object (for method chaining).
947    */
948   public RestClientBuilder ifNoneMatch(Object value) {
949      return header("If-None-Match", value);
950   }
951
952   /**
953    * Sets the value for the <c>If-Range</c> request header.
954    *
955    * <p>
956    * This is a shortcut for calling <code>header(<js>"If-Range"</js>, value);</code>
957    *
958    * @param value The new header value.
959    * @return This object (for method chaining).
960    */
961   public RestClientBuilder ifRange(Object value) {
962      return header("If-Range", value);
963   }
964
965   /**
966    * Sets the value for the <c>If-Unmodified-Since</c> request header.
967    *
968    * <p>
969    * This is a shortcut for calling <code>header(<js>"If-Unmodified-Since"</js>, value);</code>
970    *
971    * @param value The new header value.
972    * @return This object (for method chaining).
973    */
974   public RestClientBuilder ifUnmodifiedSince(Object value) {
975      return header("If-Unmodified-Since", value);
976   }
977
978   /**
979    * Sets the value for the <c>Max-Forwards</c> request header.
980    *
981    * <p>
982    * This is a shortcut for calling <code>header(<js>"Max-Forwards"</js>, value);</code>
983    *
984    * @param value The new header value.
985    * @return This object (for method chaining).
986    */
987   public RestClientBuilder maxForwards(Object value) {
988      return header("If-Unmodified-Since", value);
989   }
990
991   /**
992    * When called, <c>No-Trace: true</c> is added to requests.
993    *
994    * <p>
995    * This gives the opportunity for the servlet to not log errors on invalid requests.
996    * This is useful for testing purposes when you don't want your log file to show lots of errors that are simply the
997    * results of testing.
998    *
999    * @return This object (for method chaining).
1000    */
1001   public RestClientBuilder noTrace() {
1002      return header("No-Trace", true);
1003   }
1004
1005   /**
1006    * Sets the value for the <c>Origin</c> request header.
1007    *
1008    * <p>
1009    * This is a shortcut for calling <code>header(<js>"Origin"</js>, value);</code>
1010    *
1011    * @param value The new header value.
1012    * @return This object (for method chaining).
1013    */
1014   public RestClientBuilder origin(Object value) {
1015      return header("If-Unmodified-Since", value);
1016   }
1017
1018   /**
1019    * Sets the value for the <c>Pragma</c> request header.
1020    *
1021    * <p>
1022    * This is a shortcut for calling <code>header(<js>"Pragma"</js>, value);</code>
1023    *
1024    * @param value The new header value.
1025    * @return This object (for method chaining).
1026    */
1027   public RestClientBuilder pragma(Object value) {
1028      return header("Pragma", value);
1029   }
1030
1031   /**
1032    * Sets the value for the <c>Proxy-Authorization</c> request header.
1033    *
1034    * <p>
1035    * This is a shortcut for calling <code>header(<js>"Proxy-Authorization"</js>, value);</code>
1036    *
1037    * @param value The new header value.
1038    * @return This object (for method chaining).
1039    */
1040   public RestClientBuilder proxyAuthorization(Object value) {
1041      return header("Proxy-Authorization", value);
1042   }
1043
1044   /**
1045    * Sets the value for the <c>Range</c> request header.
1046    *
1047    * <p>
1048    * This is a shortcut for calling <code>header(<js>"Range"</js>, value);</code>
1049    *
1050    * @param value The new header value.
1051    * @return This object (for method chaining).
1052    */
1053   public RestClientBuilder range(Object value) {
1054      return header("Range", value);
1055   }
1056
1057   /**
1058    * Sets the value for the <c>Referer</c> request header.
1059    *
1060    * <p>
1061    * This is a shortcut for calling <code>header(<js>"Referer"</js>, value);</code>
1062    *
1063    * @param value The new header value.
1064    * @return This object (for method chaining).
1065    */
1066   public RestClientBuilder referer(Object value) {
1067      return header("Referer", value);
1068   }
1069
1070   /**
1071    * Sets the value for the <c>TE</c> request header.
1072    *
1073    * <p>
1074    * This is a shortcut for calling <code>header(<js>"TE"</js>, value);</code>
1075    *
1076    * @param value The new header value.
1077    * @return This object (for method chaining).
1078    */
1079   public RestClientBuilder te(Object value) {
1080      return header("TE", value);
1081   }
1082
1083   /**
1084    * Sets the value for the <c>User-Agent</c> request header.
1085    *
1086    * <p>
1087    * This is a shortcut for calling <code>header(<js>"User-Agent"</js>, value);</code>
1088    *
1089    * @param value The new header value.
1090    * @return This object (for method chaining).
1091    */
1092   public RestClientBuilder userAgent(Object value) {
1093      return header("User-Agent", value);
1094   }
1095
1096   /**
1097    * Sets the value for the <c>Upgrade</c> request header.
1098    *
1099    * <p>
1100    * This is a shortcut for calling <code>header(<js>"Upgrade"</js>, value);</code>
1101    *
1102    * @param value The new header value.
1103    * @return This object (for method chaining).
1104    */
1105   public RestClientBuilder upgrade(Object value) {
1106      return header("Upgrade", value);
1107   }
1108
1109   /**
1110    * Sets the value for the <c>Via</c> request header.
1111    *
1112    * <p>
1113    * This is a shortcut for calling <code>header(<js>"Via"</js>, value);</code>
1114    *
1115    * @param value The new header value.
1116    * @return This object (for method chaining).
1117    */
1118   public RestClientBuilder via(Object value) {
1119      return header("Via", value);
1120   }
1121
1122   /**
1123    * Sets the value for the <c>Warning</c> request header.
1124    *
1125    * <p>
1126    * This is a shortcut for calling <code>header(<js>"Warning"</js>, value);</code>
1127    *
1128    * @param value The new header value.
1129    * @return This object (for method chaining).
1130    */
1131   public RestClientBuilder warning(Object value) {
1132      return header("Warning", value);
1133   }
1134
1135   //-----------------------------------------------------------------------------------------------------------------
1136   // Properties
1137   //-----------------------------------------------------------------------------------------------------------------
1138
1139   /**
1140    * Configuration property:  Executor service.
1141    *
1142    * <p>
1143    * Defines the executor service to use when calling future methods on the {@link RestCall} class.
1144    *
1145    * <p>
1146    * This executor service is used to create {@link Future} objects on the following methods:
1147    * <ul>
1148    *    <li>{@link RestCall#runFuture()}
1149    *    <li>{@link RestCall#getResponseFuture(Class)}
1150    *    <li>{@link RestCall#getResponseFuture(Type,Type...)}
1151    *    <li>{@link RestCall#getResponseAsString()}
1152    * </ul>
1153    *
1154    * <p>
1155    * The default executor service is a single-threaded {@link ThreadPoolExecutor} with a 30 second timeout
1156    * and a queue size of 10.
1157    *
1158    * <ul class='seealso'>
1159    *    <li class='jf'>{@link RestClient#RESTCLIENT_executorService}
1160    *    <li class='jf'>{@link RestClient#RESTCLIENT_executorServiceShutdownOnClose}
1161    * </ul>
1162    *
1163    * @param executorService The executor service.
1164    * @param shutdownOnClose Call {@link ExecutorService#shutdown()} when {@link RestClient#close()} is called.
1165    * @return This object (for method chaining).
1166    */
1167   public RestClientBuilder executorService(ExecutorService executorService, boolean shutdownOnClose) {
1168      set(RESTCLIENT_executorService, executorService);
1169      set(RESTCLIENT_executorServiceShutdownOnClose, shutdownOnClose);
1170      return this;
1171   }
1172
1173   /**
1174    * Configuration property:  Request headers.
1175    *
1176    * <ul class='seealso'>
1177    *    <li class='jf'>{@link RestClient#RESTCLIENT_headers}
1178    * </ul>
1179    *
1180    * @param key The header name.
1181    * @param value The header value.
1182    * @return This object (for method chaining).
1183    */
1184   public RestClientBuilder header(String key, Object value) {
1185      return addTo(RESTCLIENT_headers, key, value);
1186   }
1187
1188   /**
1189    * Configuration property:  Keep HttpClient open.
1190    *
1191    * <p>
1192    * Don't close this client when the {@link RestClient#close()} method is called.
1193    *
1194    * <ul class='seealso'>
1195    *    <li class='jf'>{@link RestClient#RESTCLIENT_keepHttpClientOpen}
1196    * </ul>
1197    *
1198    * @param value
1199    *    The new value for this property.
1200    *    <br>The default value is <jk>false</jk>.
1201    * @return This object (for method chaining).
1202    */
1203   public RestClientBuilder keepHttpClientOpen(boolean value) {
1204      return set(RESTCLIENT_keepHttpClientOpen, value);
1205   }
1206
1207   /**
1208    * Configuration property:  Keep HttpClient open.
1209    *
1210    * <p>
1211    * Don't close this client when the {@link RestClient#close()} method is called.
1212    *
1213    * <ul class='seealso'>
1214    *    <li class='jf'>{@link RestClient#RESTCLIENT_keepHttpClientOpen}
1215    * </ul>
1216    *
1217    * @return This object (for method chaining).
1218    */
1219   public RestClientBuilder keepHttpClientOpen() {
1220      return keepHttpClientOpen(true);
1221   }
1222
1223   /**
1224    * Configuration property:  Call interceptors.
1225    *
1226    * <p>
1227    * Adds an interceptor that gets called immediately after a connection is made.
1228    *
1229    * <ul class='seealso'>
1230    *    <li class='jf'>{@link RestClient#RESTCLIENT_interceptors}
1231    * </ul>
1232    *
1233    * @param value The values to add to this setting.
1234    * @return This object (for method chaining).
1235    */
1236   public RestClientBuilder interceptors(RestCallInterceptor...value) {
1237      return addTo(RESTCLIENT_interceptors, value);
1238   }
1239
1240   /**
1241    * Configuration property:  Marshall
1242    *
1243    * <p>
1244    * Shortcut for specifying the {@link RestClient#RESTCLIENT_serializer} and {@link RestClient#RESTCLIENT_parser}
1245    * using the serializer and parser defined in a marshall.
1246    *
1247    * @param value The values to add to this setting.
1248    * @return This object (for method chaining).
1249    */
1250   public RestClientBuilder marshall(Marshall value) {
1251      if (value == null)
1252         serializer((Serializer)null).parser((Parser)null);
1253      else
1254         serializer(value.getSerializer()).parser(value.getParser());
1255      return this;
1256   }
1257
1258   /**
1259    * Configuration property:  Parser.
1260    *
1261    * <p>
1262    * The parser to use for parsing POJOs in response bodies.
1263    *
1264    * <ul class='seealso'>
1265    *    <li class='jf'>{@link RestClient#RESTCLIENT_parser}
1266    * </ul>
1267    *
1268    * @param value
1269    *    The new value for this setting.
1270    *    <br>The default value is {@link JsonParser#DEFAULT}.
1271    * @return This object (for method chaining).
1272    */
1273   public RestClientBuilder parser(Class<? extends Parser> value) {
1274      return set(RESTCLIENT_parser, value);
1275   }
1276
1277   /**
1278    * Configuration property:  Parser.
1279    *
1280    * <p>
1281    * Same as {@link #parser(Parser)} except takes in a parser instance.
1282    *
1283    * <ul class='seealso'>
1284    *    <li class='jf'>{@link RestClient#RESTCLIENT_parser}
1285    * </ul>
1286    *
1287    * @param value
1288    *    The new value for this setting.
1289    *    <br>The default value is {@link JsonParser#DEFAULT}.
1290    * @return This object (for method chaining).
1291    */
1292   public RestClientBuilder parser(Parser value) {
1293      return set(RESTCLIENT_parser, value);
1294   }
1295
1296   /**
1297    * Configuration property:  Part parser.
1298    *
1299    * <p>
1300    * The parser to use for parsing POJOs from form data, query parameters, headers, and path variables.
1301    *
1302    * <ul class='seealso'>
1303    *    <li class='jf'>{@link RestClient#RESTCLIENT_partParser}
1304    * </ul>
1305    *
1306    * @param value
1307    *    The new value for this setting.
1308    *    <br>The default value is {@link OpenApiParser}.
1309    * @return This object (for method chaining).
1310    */
1311   public RestClientBuilder partParser(Class<? extends HttpPartParser> value) {
1312      return set(RESTCLIENT_partParser, value);
1313   }
1314
1315   /**
1316    * Configuration property:  Part parser.
1317    *
1318    * <p>
1319    * Same as {@link #partParser(Class)} but takes in a parser instance.
1320    *
1321    * <ul class='seealso'>
1322    *    <li class='jf'>{@link RestClient#RESTCLIENT_partParser}
1323    * </ul>
1324    *
1325    * @param value
1326    *    The new value for this setting.
1327    *    <br>The default value is {@link OpenApiParser}.
1328    * @return This object (for method chaining).
1329    */
1330   public RestClientBuilder partParser(HttpPartParser value) {
1331      return set(RESTCLIENT_partParser, value);
1332   }
1333
1334   /**
1335    * Configuration property:  Part serializer.
1336    *
1337    * <p>
1338    * The serializer to use for serializing POJOs in form data, query parameters, headers, and path variables.
1339    *
1340    * <ul class='seealso'>
1341    *    <li class='jf'>{@link RestClient#RESTCLIENT_partSerializer}
1342    * </ul>
1343    *
1344    * @param value
1345    *    The new value for this setting.
1346    *    <br>The default value is {@link OpenApiSerializer}.
1347    * @return This object (for method chaining).
1348    */
1349   public RestClientBuilder partSerializer(Class<? extends HttpPartSerializer> value) {
1350      return set(RESTCLIENT_partSerializer, value);
1351   }
1352
1353   /**
1354    * Configuration property:  Part serializer.
1355    *
1356    * <p>
1357    * Same as {@link #partSerializer(Class)} but takes in a parser instance.
1358    *
1359    * <ul class='seealso'>
1360    *    <li class='jf'>{@link RestClient#RESTCLIENT_partSerializer}
1361    * </ul>
1362    *
1363    * @param value
1364    *    The new value for this setting.
1365    *    <br>The default value is {@link OpenApiSerializer}.
1366    * @return This object (for method chaining).
1367    */
1368   public RestClientBuilder partSerializer(HttpPartSerializer value) {
1369      return set(RESTCLIENT_partSerializer, value);
1370   }
1371
1372   /**
1373    * Make HTTP calls retryable if an error response (>=400) is received.
1374    *
1375    * <ul class='seealso'>
1376    *    <li class='jf'>{@link RestClient#RESTCLIENT_retries}
1377    *    <li class='jf'>{@link RestClient#RESTCLIENT_retryInterval}
1378    *    <li class='jf'>{@link RestClient#RESTCLIENT_retryOn}
1379    * </ul>
1380    *
1381    * @param retries The number of retries to attempt.
1382    * @param interval The time in milliseconds between attempts.
1383    * @param retryOn
1384    *    Optional object used for determining whether a retry should be attempted.
1385    *    If <jk>null</jk>, uses {@link RetryOn#DEFAULT}.
1386    * @return This object (for method chaining).
1387    */
1388   public RestClientBuilder retryable(int retries, int interval, RetryOn retryOn) {
1389      set(RESTCLIENT_retries, retries);
1390      set(RESTCLIENT_retryInterval, interval);
1391      set(RESTCLIENT_retryOn, retryOn);
1392      return this;
1393   }
1394
1395   /**
1396    * Configuration property:  Root URI.
1397    *
1398    * <p>
1399    * When set, relative URL strings passed in through the various rest call methods (e.g. {@link RestClient#doGet(Object)}
1400    * will be prefixed with the specified root.
1401    * <br>This root URL is ignored on those methods if you pass in a {@link URL}, {@link URI}, or an absolute URL string.
1402    *
1403    * <ul class='seealso'>
1404    *    <li class='jf'>{@link RestClient#RESTCLIENT_rootUri}
1405    * </ul>
1406    *
1407    * @param value
1408    *    The root URL to prefix to relative URL strings.
1409    *    <br>Trailing slashes are trimmed.
1410    *    <br>Usually a <c>String</c> but you can also pass in <c>URI</c> and <c>URL</c> objects as well.
1411    * @return This object (for method chaining).
1412    */
1413   public RestClientBuilder rootUrl(Object value) {
1414      return set(RESTCLIENT_rootUri, value);
1415   }
1416
1417   /**
1418    * Configuration property:  Request query parameters.
1419    *
1420    * <ul class='seealso'>
1421    *    <li class='jf'>{@link RestClient#RESTCLIENT_query}
1422    * </ul>
1423    *
1424    * @param key The query parameter name.
1425    * @param value The query parameter value value.
1426    * @return This object (for method chaining).
1427    */
1428   public RestClientBuilder query(String key, Object value) {
1429      return addTo(RESTCLIENT_query, key, value);
1430   }
1431
1432   /**
1433    * Configuration property:  Serializer.
1434    *
1435    * <p>
1436    * The serializer to use for serializing POJOs in request bodies.
1437    *
1438    * <ul class='seealso'>
1439    *    <li class='jf'>{@link RestClient#RESTCLIENT_serializer}
1440    * </ul>
1441    *
1442    * @param value
1443    *    The new value for this setting.
1444    *    <br>The default is {@link JsonSerializer}.
1445    * @return This object (for method chaining).
1446    */
1447   public RestClientBuilder serializer(Class<? extends Serializer> value) {
1448      return set(RESTCLIENT_serializer, value);
1449   }
1450
1451   /**
1452    * Configuration property:  Serializer.
1453    *
1454    * <p>
1455    * Same as {@link #serializer(Class)} but takes in a serializer instance.
1456    *
1457    * <ul class='seealso'>
1458    *    <li class='jf'>{@link RestClient#RESTCLIENT_serializer}
1459    * </ul>
1460    *
1461    * @param value
1462    *    The new value for this setting.
1463    *    <br>The default is {@link JsonSerializer}.
1464    * @return This object (for method chaining).
1465    */
1466   public RestClientBuilder serializer(Serializer value) {
1467      return set(RESTCLIENT_serializer, value);
1468   }
1469
1470   /**
1471    * Configuration property:  Add <js>"_type"</js> properties when needed.
1472    *
1473    * <p>
1474    * If <jk>true</jk>, then <js>"_type"</js> properties will be added to beans if their type cannot be inferred
1475    * through reflection.
1476    *
1477    * <ul class='seealso'>
1478    *    <li class='jf'>{@link Serializer#SERIALIZER_addBeanTypes}
1479    * </ul>
1480    *
1481    * @param value
1482    *    The new value for this property.
1483    *    <br>The default is <jk>false</jk>.
1484    * @return This object (for method chaining).
1485    */
1486   public RestClientBuilder addBeanTypes(boolean value) {
1487      return set(SERIALIZER_addBeanTypes, value);
1488   }
1489
1490   /**
1491    * Configuration property:  Add <js>"_type"</js> properties when needed.
1492    *
1493    * <p>
1494    * Shortcut for calling <code>addBeanTypes(<jk>true</jk>)</code>.
1495    *
1496    * <ul class='seealso'>
1497    *    <li class='jf'>{@link Serializer#SERIALIZER_addBeanTypes}
1498    * </ul>
1499    *
1500    * @return This object (for method chaining).
1501    */
1502   public RestClientBuilder addBeanTypes() {
1503      return set(SERIALIZER_addBeanTypes, true);
1504   }
1505
1506   /**
1507    * Configuration property:  Add type attribute to root nodes.
1508    *
1509    * <p>
1510    * When disabled, it is assumed that the parser knows the exact Java POJO type being parsed, and therefore top-level
1511    * type information that might normally be included to determine the data type will not be serialized.
1512    *
1513    * <ul class='seealso'>
1514    *    <li class='jf'>{@link Serializer#SERIALIZER_addRootType}
1515    * </ul>
1516    *
1517    * @param value
1518    *    The new value for this property.
1519    *    <br>The default is <jk>false</jk>.
1520    * @return This object (for method chaining).
1521    */
1522   public RestClientBuilder addRootType(boolean value) {
1523      return set(SERIALIZER_addRootType, value);
1524   }
1525
1526   /**
1527    * Configuration property:  Add type attribute to root nodes.
1528    *
1529    * <p>
1530    * Shortcut for calling <code>addRootType(<jk>true</jk>)</code>.
1531    *
1532    * <ul class='seealso'>
1533    *    <li class='jf'>{@link Serializer#SERIALIZER_addRootType}
1534    * </ul>
1535    *
1536    * @return This object (for method chaining).
1537    */
1538   public RestClientBuilder addRootType() {
1539      return set(SERIALIZER_addRootType, true);
1540   }
1541
1542   /**
1543    * Configuration property:  Automatically detect POJO recursions.
1544    *
1545    * <p>
1546    * Specifies that recursions should be checked for during serialization.
1547    *
1548    * <ul class='notes'>
1549    *    <li>
1550    *       Checking for recursion can cause a small performance penalty.
1551    * </ul>
1552    *
1553    * <ul class='seealso'>
1554    *    <li class='jf'>{@link BeanTraverseContext#BEANTRAVERSE_detectRecursions}
1555    * </ul>
1556    *
1557    * @param value
1558    *    The new value for this property.
1559    *    <br>The default is <jk>false</jk>.
1560    * @return This object (for method chaining).
1561    */
1562   public RestClientBuilder detectRecursions(boolean value) {
1563      return set(BEANTRAVERSE_detectRecursions, value);
1564   }
1565
1566   /**
1567    * Configuration property:  Automatically detect POJO recursions.
1568    *
1569    * <p>
1570    * Shortcut for calling <code>detectRecursions(<jk>true</jk>)</code>.
1571    *
1572    * <ul class='seealso'>
1573    *    <li class='jf'>{@link BeanTraverseContext#BEANTRAVERSE_detectRecursions}
1574    * </ul>
1575    *
1576    * @return This object (for method chaining).
1577    */
1578   public RestClientBuilder detectRecursions() {
1579      return set(BEANTRAVERSE_detectRecursions, true);
1580   }
1581
1582   /**
1583    * Configuration property:  Ignore recursion errors.
1584    *
1585    * <p>
1586    * If <jk>true</jk>, when we encounter the same object when serializing a tree, we set the value to <jk>null</jk>.
1587    * Otherwise, an exception is thrown.
1588    *
1589    * <ul class='notes'>
1590    *    <li>
1591    *       Checking for recursion can cause a small performance penalty.
1592    * </ul>
1593    *
1594    * <ul class='seealso'>
1595    *    <li class='jf'>{@link BeanTraverseContext#BEANTRAVERSE_ignoreRecursions}
1596    * </ul>
1597    *
1598    * @param value
1599    *    The new value for this property.
1600    *    <br>The default is <jk>false</jk>.
1601    * @return This object (for method chaining).
1602    */
1603   public RestClientBuilder ignoreRecursions(boolean value) {
1604      return set(BEANTRAVERSE_ignoreRecursions, value);
1605   }
1606
1607   /**
1608    * Configuration property:  Ignore recursion errors.
1609    *
1610    * <p>
1611    * Shortcut for calling <code>ignoreRecursions(<jk>true</jk>)</code>.
1612    *
1613    * <ul class='seealso'>
1614    *    <li class='jf'>{@link BeanTraverseContext#BEANTRAVERSE_ignoreRecursions}
1615    * </ul>
1616    *
1617    * @return This object (for method chaining).
1618    */
1619   public RestClientBuilder ignoreRecursions() {
1620      return set(BEANTRAVERSE_ignoreRecursions, true);
1621   }
1622
1623   /**
1624    * Configuration property:  Initial depth.
1625    *
1626    * <p>
1627    * The initial indentation level at the root.
1628    *
1629    * <ul class='seealso'>
1630    *    <li class='jf'>{@link BeanTraverseContext#BEANTRAVERSE_initialDepth}
1631    * </ul>
1632    *
1633    * @param value
1634    *    The new value for this property.
1635    *    <br>The default is <c>0</c>.
1636    * @return This object (for method chaining).
1637    */
1638   public RestClientBuilder initialDepth(int value) {
1639      return set(BEANTRAVERSE_initialDepth, value);
1640   }
1641
1642   /**
1643    * Configuration property:  Serializer listener.
1644    *
1645    * <p>
1646    * Class used to listen for errors and warnings that occur during serialization.
1647    *
1648    * <ul class='seealso'>
1649    *    <li class='jf'>{@link Serializer#SERIALIZER_listener}
1650    * </ul>
1651    *
1652    * @param value
1653    *    The new value for this property.
1654    * @return This object (for method chaining).
1655    */
1656   public RestClientBuilder listenerS(Class<? extends SerializerListener> value) {
1657      return set(SERIALIZER_listener, value);
1658   }
1659
1660   /**
1661    * Configuration property:  Max serialization depth.
1662    *
1663    * <p>
1664    * Abort serialization if specified depth is reached in the POJO tree.
1665    * <br>If this depth is exceeded, an exception is thrown.
1666    * <br>This prevents stack overflows from occurring when trying to serialize models with recursive references.
1667    *
1668    * <ul class='seealso'>
1669    *    <li class='jf'>{@link BeanTraverseContext#BEANTRAVERSE_maxDepth}
1670    * </ul>
1671    *
1672    * @param value
1673    *    The new value for this property.
1674    *    <br>The default is <c>100</c>.
1675    * @return This object (for method chaining).
1676    */
1677   public RestClientBuilder maxDepth(int value) {
1678      return set(BEANTRAVERSE_maxDepth, value);
1679   }
1680
1681   /**
1682    * Configuration property:  Sort arrays and collections alphabetically.
1683    *
1684    * <p>
1685    * Copies and sorts the contents of arrays and collections before serializing them.
1686    *
1687    * <ul class='seealso'>
1688    *    <li class='jf'>{@link Serializer#SERIALIZER_sortCollections}
1689    * </ul>
1690    *
1691    * @param value
1692    *    The new value for this property.
1693    *    <br>The default is <jk>false</jk>.
1694    * @return This object (for method chaining).
1695    */
1696   public RestClientBuilder sortCollections(boolean value) {
1697      return set(SERIALIZER_sortCollections, value);
1698   }
1699
1700   /**
1701    * Configuration property:  Sort arrays and collections alphabetically.
1702    *
1703    * <p>
1704    * Shortcut for calling <code>sortCollections(<jk>true</jk>)</code>.
1705    *
1706    * <ul class='seealso'>
1707    *    <li class='jf'>{@link Serializer#SERIALIZER_sortCollections}
1708    * </ul>
1709    *
1710    * @return This object (for method chaining).
1711    */
1712   public RestClientBuilder sortCollections() {
1713      return set(SERIALIZER_sortCollections, true);
1714   }
1715
1716   /**
1717    * Sets the {@link Serializer#SERIALIZER_sortMaps} property on all serializers in this group.
1718    *
1719    * <p>
1720    * Copies and sorts the contents of maps before serializing them.
1721    *
1722    * <ul class='seealso'>
1723    *    <li class='jf'>{@link Serializer#SERIALIZER_sortMaps}
1724    * </ul>
1725    *
1726    * @param value The new value for this property.
1727    * @return This object (for method chaining).
1728    */
1729   public RestClientBuilder sortMaps(boolean value) {
1730      return set(SERIALIZER_sortMaps, value);
1731   }
1732
1733   /**
1734    * Configuration property:  Sort maps alphabetically.
1735    *
1736    * <p>
1737    * Shortcut for calling <code>sortMaps(<jk>true</jk>)</code>.
1738    *
1739    * <ul class='seealso'>
1740    *    <li class='jf'>{@link Serializer#SERIALIZER_sortMaps}
1741    * </ul>
1742    *
1743    * @return This object (for method chaining).
1744    */
1745   public RestClientBuilder sortMaps() {
1746      return set(SERIALIZER_sortMaps, true);
1747   }
1748
1749   /**
1750    * Configuration property:  Trim empty lists and arrays.
1751    *
1752    * <p>
1753    * If <jk>true</jk>, empty list values will not be serialized to the output.
1754    *
1755    * <ul class='seealso'>
1756    *    <li class='jf'>{@link Serializer#SERIALIZER_trimEmptyCollections}
1757    * </ul>
1758    *
1759    * @param value
1760    *    The new value for this property.
1761    *    <br>The default is <jk>false</jk>.
1762    * @return This object (for method chaining).
1763    */
1764   public RestClientBuilder trimEmptyCollections(boolean value) {
1765      return set(SERIALIZER_trimEmptyCollections, value);
1766   }
1767
1768   /**
1769    * Configuration property:  Trim empty lists and arrays.
1770    *
1771    * <p>
1772    * Shortcut for calling <code>trimEmptyCollections(<jk>true</jk>)</code>.
1773    *
1774    * <ul class='seealso'>
1775    *    <li class='jf'>{@link Serializer#SERIALIZER_trimEmptyCollections}
1776    * </ul>
1777    *
1778    * @return This object (for method chaining).
1779    */
1780   public RestClientBuilder trimEmptyCollections() {
1781      return set(SERIALIZER_trimEmptyCollections, true);
1782   }
1783
1784   /**
1785    * Configuration property:  Trim empty maps.
1786    *
1787    * <p>
1788    * If <jk>true</jk>, empty map values will not be serialized to the output.
1789    *
1790    * <ul class='seealso'>
1791    *    <li class='jf'>{@link Serializer#SERIALIZER_trimEmptyMaps}
1792    * </ul>
1793    *
1794    * @param value
1795    *    The new value for this property.
1796    *    <br>The default is <jk>false</jk>.
1797    * @return This object (for method chaining).
1798    */
1799   public RestClientBuilder trimEmptyMaps(boolean value) {
1800      return set(SERIALIZER_trimEmptyMaps, value);
1801   }
1802
1803   /**
1804    * Configuration property:  Trim empty maps.
1805    *
1806    * <p>
1807    * Shortcut for calling <code>trimEmptyMaps(<jk>true</jk>)</code>.
1808    *
1809    * <ul class='seealso'>
1810    *    <li class='jf'>{@link Serializer#SERIALIZER_trimEmptyMaps}
1811    * </ul>
1812    *
1813    * @return This object (for method chaining).
1814    */
1815   public RestClientBuilder trimEmptyMaps() {
1816      return set(SERIALIZER_trimEmptyMaps, true);
1817   }
1818
1819   /**
1820    * Configuration property:  Trim null bean property values.
1821    *
1822    * <p>
1823    * If <jk>true</jk>, null bean values will not be serialized to the output.
1824    *
1825    * <ul class='seealso'>
1826    *    <li class='jf'>{@link Serializer#SERIALIZER_trimNullProperties}
1827    * </ul>
1828    *
1829    * @param value
1830    *    The new value for this property.
1831    *    <br>The default is <jk>true</jk>.
1832    * @return This object (for method chaining).
1833    */
1834   public RestClientBuilder trimNullProperties(boolean value) {
1835      return set(SERIALIZER_trimNullProperties, value);
1836   }
1837
1838   /**
1839    * Configuration property:  Trim strings.
1840    *
1841    * <p>
1842    * If <jk>true</jk>, string values will be trimmed of whitespace using {@link String#trim()} before being serialized.
1843    *
1844    * <ul class='seealso'>
1845    *    <li class='jf'>{@link Serializer#SERIALIZER_trimStrings}
1846    * </ul>
1847    *
1848    * @param value
1849    *    The new value for this property.
1850    *    <br>The default is <jk>false</jk>.
1851    * @return This object (for method chaining).
1852    */
1853   public RestClientBuilder trimStringsS(boolean value) {
1854      return set(SERIALIZER_trimStrings, value);
1855   }
1856
1857   /**
1858    * Configuration property:  Trim strings.
1859    *
1860    * <p>
1861    * Shortcut for calling <code>trimStrings(<jk>true</jk>)</code>.
1862    *
1863    * <ul class='seealso'>
1864    *    <li class='jf'>{@link Serializer#SERIALIZER_trimStrings}
1865    * </ul>
1866    *
1867    * @return This object (for method chaining).
1868    */
1869   public RestClientBuilder trimStringsS() {
1870      return set(SERIALIZER_trimStrings, true);
1871   }
1872
1873   /**
1874    * Configuration property:  URI context bean.
1875    *
1876    * <p>
1877    * Bean used for resolution of URIs to absolute or root-relative form.
1878    *
1879    * <ul class='seealso'>
1880    *    <li class='jf'>{@link Serializer#SERIALIZER_uriContext}
1881    * </ul>
1882    *
1883    * @param value The new value for this property.
1884    * @return This object (for method chaining).
1885    */
1886   public RestClientBuilder uriContext(UriContext value) {
1887      return set(SERIALIZER_uriContext, value);
1888   }
1889
1890   /**
1891    * Configuration property:  URI relativity.
1892    *
1893    * <p>
1894    * Defines what relative URIs are relative to when serializing URI/URL objects.
1895    *
1896    * <ul class='seealso'>
1897    *    <li class='jf'>{@link Serializer#SERIALIZER_uriRelativity}
1898    * </ul>
1899    *
1900    * @param value
1901    *    The new value for this property.
1902    *    <br>The default is {@link UriRelativity#RESOURCE}
1903    * @return This object (for method chaining).
1904    */
1905   public RestClientBuilder uriRelativity(UriRelativity value) {
1906      return set(SERIALIZER_uriRelativity, value);
1907   }
1908
1909   /**
1910    * Configuration property:  URI resolution.
1911    *
1912    * <p>
1913    * Defines the resolution level for URIs when serializing URI/URL objects.
1914    *
1915    * <ul class='seealso'>
1916    *    <li class='jf'>{@link Serializer#SERIALIZER_uriResolution}
1917    * </ul>
1918    *
1919    * @param value
1920    *    The new value for this property.
1921    *    <br>The default is {@link UriResolution#NONE}
1922    * @return This object (for method chaining).
1923    */
1924   public RestClientBuilder uriResolution(UriResolution value) {
1925      return set(SERIALIZER_uriResolution, value);
1926   }
1927
1928   /**
1929    * Configuration property:  Maximum indentation.
1930    *
1931    * <p>
1932    * Specifies the maximum indentation level in the serialized document.
1933    *
1934    * <ul class='seealso'>
1935    *    <li class='jf'>{@link WriterSerializer#WSERIALIZER_maxIndent}
1936    * </ul>
1937    *
1938    * @param value
1939    *    The new value for this property.
1940    *    <br>The default is <c>100</c>.
1941    * @return This object (for method chaining).
1942    */
1943   public RestClientBuilder maxIndent(int value) {
1944      return set(WSERIALIZER_maxIndent, value);
1945   }
1946
1947   /**
1948    * Configuration property:  Quote character.
1949    *
1950    * <p>
1951    * This is the character used for quoting attributes and values.
1952    *
1953    * <ul class='seealso'>
1954    *    <li class='jf'>{@link WriterSerializer#WSERIALIZER_quoteChar}
1955    * </ul>
1956    *
1957    * @param value
1958    *    The new value for this property.
1959    *    <br>The default is <js>'"'</js>.
1960    * @return This object (for method chaining).
1961    */
1962   public RestClientBuilder quoteChar(char value) {
1963      return set(WSERIALIZER_quoteChar, value);
1964   }
1965
1966   /**
1967    * Configuration property:  Quote character.
1968    *
1969    * <p>
1970    * Shortcut for calling <code>quoteChar(<js>'\''</js>)</code>.
1971    *
1972    * <ul class='seealso'>
1973    *    <li class='jf'>{@link WriterSerializer#WSERIALIZER_quoteChar}
1974    * </ul>
1975    *
1976    * @return This object (for method chaining).
1977    */
1978   public RestClientBuilder sq() {
1979      return set(WSERIALIZER_quoteChar, '\'');
1980   }
1981
1982   /**
1983    * Configuration property:  Use whitespace.
1984    *
1985    * <p>
1986    * If <jk>true</jk>, newlines and indentation and spaces are added to the output to improve readability.
1987    *
1988    * <ul class='seealso'>
1989    *    <li class='jf'>{@link WriterSerializer#WSERIALIZER_useWhitespace}
1990    * </ul>
1991    *
1992    * @param value
1993    *    The new value for this property.
1994    *    <br>The default is <jk>false</jk>.
1995    * @return This object (for method chaining).
1996    */
1997   public RestClientBuilder useWhitespace(boolean value) {
1998      return set(WSERIALIZER_useWhitespace, value);
1999   }
2000
2001   /**
2002    * Configuration property:  Use whitespace.
2003    *
2004    * <p>
2005    * Shortcut for calling <code>useWhitespace(<jk>true</jk>)</code>.
2006    *
2007    * <ul class='seealso'>
2008    *    <li class='jf'>{@link WriterSerializer#WSERIALIZER_useWhitespace}
2009    * </ul>
2010    * @return This object (for method chaining).
2011    */
2012   public RestClientBuilder useWhitespace() {
2013      return set(WSERIALIZER_useWhitespace, true);
2014   }
2015
2016   /**
2017    * Configuration property:  Use whitespace.
2018    *
2019    * <p>
2020    * Shortcut for calling <code>useWhitespace(<jk>true</jk>)</code>.
2021    *
2022    * <ul class='seealso'>
2023    *    <li class='jf'>{@link WriterSerializer#WSERIALIZER_useWhitespace}
2024    * </ul>
2025    *
2026    * @return This object (for method chaining).
2027    */
2028   public RestClientBuilder ws() {
2029      return set(WSERIALIZER_useWhitespace, true);
2030   }
2031
2032   /**
2033    * Configuration property:  Binary string format.
2034    *
2035    * <p>
2036    * When using the {@link Serializer#serializeToString(Object)} method on stream-based serializers, this defines the format to use
2037    * when converting the resulting byte array to a string.
2038    *
2039    * <ul class='javatree'>
2040    *    <li class='jf'>{@link OutputStreamSerializer#OSSERIALIZER_binaryFormat}
2041    * </ul>
2042    *
2043    * @param value
2044    *    The new value for this property.
2045    *    <br>The default is {@link BinaryFormat#HEX}.
2046    * @return This object (for method chaining).
2047    */
2048   public RestClientBuilder binaryOutputFormat(BinaryFormat value) {
2049      return set(OSSERIALIZER_binaryFormat, value);
2050   }
2051
2052   /**
2053    * Configuration property:  Auto-close streams.
2054    *
2055    * If <jk>true</jk>, <l>InputStreams</l> and <l>Readers</l> passed into parsers will be closed
2056    * after parsing is complete.
2057    *
2058    * <ul class='seealso'>
2059    *    <li class='jf'>{@link Parser#PARSER_autoCloseStreams}
2060    * </ul>
2061    *
2062    * @param value
2063    *    The new value for this property.
2064    *    <br>The default value is <jk>false</jk>.
2065    * @return This object (for method chaining).
2066    */
2067   public RestClientBuilder autoCloseStreams(boolean value) {
2068      return set(PARSER_autoCloseStreams, value);
2069   }
2070
2071   /**
2072    * Configuration property:  Auto-close streams.
2073    *
2074    * <p>
2075    * Shortcut for calling <code>autoCloseStreams(<jk>true</jk>)</code>.
2076    *
2077    * <ul class='seealso'>
2078    *    <li class='jf'>{@link Parser#PARSER_autoCloseStreams}
2079    * </ul>
2080    *
2081    * @return This object (for method chaining).
2082    */
2083   public RestClientBuilder autoCloseStreams() {
2084      return set(PARSER_autoCloseStreams, true);
2085   }
2086
2087   /**
2088    * Configuration property:  Debug output lines.
2089    *
2090    * When parse errors occur, this specifies the number of lines of input before and after the
2091    * error location to be printed as part of the exception message.
2092    *
2093    * <ul class='seealso'>
2094    *    <li class='jf'>{@link Parser#PARSER_debugOutputLines}
2095    * </ul>
2096    *
2097    * @param value
2098    *    The new value for this property.
2099    *    <br>The default value is <c>5</c>.
2100    * @return This object (for method chaining).
2101    */
2102   public RestClientBuilder debugOutputLines(int value) {
2103      set(PARSER_debugOutputLines, value);
2104      return this;
2105   }
2106
2107   /**
2108    * Configuration property:  Parser listener.
2109    *
2110    * <p>
2111    * Class used to listen for errors and warnings that occur during parsing.
2112    *
2113    * <ul class='seealso'>
2114    *    <li class='jf'>{@link Parser#PARSER_listener}
2115    * </ul>
2116    *
2117    * @param value The new value for this property.
2118    * @return This object (for method chaining).
2119    */
2120   public RestClientBuilder listenerP(Class<? extends ParserListener> value) {
2121      return set(PARSER_listener, value);
2122   }
2123
2124   /**
2125    * Configuration property:  Strict mode.
2126    *
2127    * <p>
2128    * If <jk>true</jk>, strict mode for the parser is enabled.
2129    *
2130    * <ul class='seealso'>
2131    *    <li class='jf'>{@link Parser#PARSER_strict}
2132    * </ul>
2133    *
2134    * @param value
2135    *    The new value for this property.
2136    *    <br>The default value is <jk>false</jk>.
2137    * @return This object (for method chaining).
2138    */
2139   public RestClientBuilder strict(boolean value) {
2140      return set(PARSER_strict, value);
2141   }
2142
2143   /**
2144    * Configuration property:  Strict mode.
2145    *
2146    * <p>
2147    * Shortcut for calling <code>strict(<jk>true</jk>)</code>.
2148    *
2149    * <ul class='seealso'>
2150    *    <li class='jf'>{@link Parser#PARSER_strict}
2151    * </ul>
2152    *
2153    * @return This object (for method chaining).
2154    */
2155   public RestClientBuilder strict() {
2156      return set(PARSER_strict, true);
2157   }
2158
2159   /**
2160    * Configuration property:  Trim parsed strings.
2161    *
2162    * <p>
2163    * If <jk>true</jk>, string values will be trimmed of whitespace using {@link String#trim()} before being added to
2164    * the POJO.
2165    *
2166    * <ul class='seealso'>
2167    *    <li class='jf'>{@link Parser#PARSER_trimStrings}
2168    * </ul>
2169    *
2170    * @param value
2171    *    The new value for this property.
2172    *    <br>The default value is <jk>false</jk>.
2173    * @return This object (for method chaining).
2174    */
2175   public RestClientBuilder trimStringsP(boolean value) {
2176      return set(PARSER_trimStrings, value);
2177   }
2178
2179   /**
2180    * Configuration property:  Trim parsed strings.
2181    *
2182    * <p>
2183    * Shortcut for calling <code>trimStrings(<jk>true</jk>)</code>.
2184    *
2185    * <ul class='seealso'>
2186    *    <li class='jf'>{@link Parser#PARSER_trimStrings}
2187    * </ul>
2188    *
2189    * @return This object (for method chaining).
2190    */
2191   public RestClientBuilder trimStringsP() {
2192      return set(PARSER_trimStrings, true);
2193   }
2194
2195   /**
2196    * Configuration property:  Unbuffered.
2197    *
2198    * If <jk>true</jk>, don't use internal buffering during parsing.
2199    *
2200    * <ul class='seealso'>
2201    *    <li class='jf'>{@link Parser#PARSER_unbuffered}
2202    * </ul>
2203    *
2204    * @param value
2205    *    The new value for this property.
2206    *    <br>The default value is <jk>false</jk>.
2207    * @return This object (for method chaining).
2208    */
2209   public RestClientBuilder unbuffered(boolean value) {
2210      return set(PARSER_unbuffered, value);
2211   }
2212
2213   /**
2214    * Configuration property:  Unbuffered.
2215    *
2216    * <p>
2217    * Shortcut for calling <code>unbuffered(<jk>true</jk>)</code>.
2218    *
2219    * <ul class='seealso'>
2220    *    <li class='jf'>{@link Parser#PARSER_unbuffered}
2221    * </ul>
2222    *
2223    * @return This object (for method chaining).
2224    */
2225   public RestClientBuilder unbuffered() {
2226      return set(PARSER_unbuffered, true);
2227   }
2228
2229   /**
2230    * Configuration property:  File charset.
2231    *
2232    * <p>
2233    * The character set to use for reading <c>Files</c> from the file system.
2234    *
2235    * <ul class='seealso'>
2236    *    <li class='jf'>{@link ReaderParser#RPARSER_fileCharset}
2237    * </ul>
2238    *
2239    * @param value
2240    *    The new value for this property.
2241    *    <br>The default value is <js>"DEFAULT"</js> which causes the system default to be used.
2242    * @return This object (for method chaining).
2243    */
2244   public RestClientBuilder fileCharset(String value) {
2245      return set(RPARSER_fileCharset, value);
2246   }
2247
2248   /**
2249    * Configuration property:  Input stream charset.
2250    *
2251    * <p>
2252    * The character set to use for converting <c>InputStreams</c> and byte arrays to readers.
2253    *
2254    * <ul class='seealso'>
2255    *    <li class='jf'>{@link ReaderParser#RPARSER_streamCharset}
2256    * </ul>
2257    *
2258    * @param value
2259    *    The new value for this property.
2260    *    <br>The default value is <js>"UTF-8"</js>.
2261    * @return This object (for method chaining).
2262    */
2263   public RestClientBuilder inputStreamCharset(String value) {
2264      return set(RPARSER_streamCharset, value);
2265   }
2266
2267   /**
2268    * Configuration property:  Binary input format.
2269    *
2270    * <p>
2271    * 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
2272    * when converting the string into a byte array.
2273    *
2274    * <ul class='seealso'>
2275    *    <li class='jf'>{@link InputStreamParser#ISPARSER_binaryFormat}
2276    * </ul>
2277    *
2278    * @param value
2279    *    The new value for this property.
2280    *    <br>The default value is {@link BinaryFormat#HEX}.
2281    * @return This object (for method chaining).
2282    */
2283   public RestClientBuilder binaryInputFormat(BinaryFormat value) {
2284      return set(ISPARSER_binaryFormat, value);
2285   }
2286
2287   /**
2288    * Configuration property:  Parameter format.
2289    *
2290    * <ul class='seealso'>
2291    *    <li class='jf'>{@link UonSerializer#UON_paramFormat}
2292    * </ul>
2293    *
2294    * @param value The new value for this property.
2295    * @return This object (for method chaining).
2296    */
2297   public RestClientBuilder paramFormat(String value) {
2298      return set(UON_paramFormat, value);
2299   }
2300
2301   /**
2302    * Configuration property:  Parameter format.
2303    *
2304    * <ul class='seealso'>
2305    *    <li class='jf'>{@link UonSerializer#UON_paramFormat}
2306    * </ul>
2307    *
2308    * @return This object (for method chaining).
2309    */
2310   public RestClientBuilder paramFormatPlain() {
2311      return set(UON_paramFormat, "PLAINTEXT");
2312   }
2313
2314   @Override /* BeanContextBuilder */
2315   public RestClientBuilder beanClassVisibility(Visibility value) {
2316      super.beanClassVisibility(value);
2317      return this;
2318   }
2319
2320   @Override /* BeanContextBuilder */
2321   public RestClientBuilder beanConstructorVisibility(Visibility value) {
2322      super.beanConstructorVisibility(value);
2323      return this;
2324   }
2325
2326   @Override /* BeanContextBuilder */
2327   @Deprecated
2328   public RestClientBuilder beanDictionary(Class<?>...values) {
2329      super.beanDictionary(values);
2330      return this;
2331   }
2332
2333   @Override /* BeanContextBuilder */
2334   @Deprecated
2335   public RestClientBuilder beanDictionary(Object...values) {
2336      super.beanDictionary(values);
2337      return this;
2338   }
2339
2340   @Override /* BeanContextBuilder */
2341   @Deprecated
2342   public RestClientBuilder beanDictionaryReplace(Class<?>...values) {
2343      super.beanDictionaryReplace(values);
2344      return this;
2345   }
2346
2347   @Override /* BeanContextBuilder */
2348   @Deprecated
2349   public RestClientBuilder beanDictionaryReplace(Object...values) {
2350      super.beanDictionaryReplace(values);
2351      return this;
2352   }
2353
2354   @Override /* BeanContextBuilder */
2355   @Deprecated
2356   public RestClientBuilder beanDictionaryRemove(Class<?>...values) {
2357      super.beanDictionaryRemove(values);
2358      return this;
2359   }
2360
2361   @Override /* BeanContextBuilder */
2362   @Deprecated
2363   public RestClientBuilder beanDictionaryRemove(Object...values) {
2364      super.beanDictionaryRemove(values);
2365      return this;
2366   }
2367
2368   @Override /* BeanContextBuilder */
2369   public RestClientBuilder beanFieldVisibility(Visibility value) {
2370      super.beanFieldVisibility(value);
2371      return this;
2372   }
2373
2374   @Override /* BeanContextBuilder */
2375   public RestClientBuilder beanFilters(Class<?>...values) {
2376      super.beanFilters(values);
2377      return this;
2378   }
2379
2380   @Override /* BeanContextBuilder */
2381   public RestClientBuilder beanFilters(Object...values) {
2382      super.beanFilters(values);
2383      return this;
2384   }
2385
2386   @Override /* BeanContextBuilder */
2387   public RestClientBuilder beanFiltersReplace(Class<?>...values) {
2388      super.beanFiltersReplace(values);
2389      return this;
2390   }
2391
2392   @Override /* BeanContextBuilder */
2393   public RestClientBuilder beanFiltersReplace(Object...values) {
2394      super.beanFiltersReplace(values);
2395      return this;
2396   }
2397
2398   @Override /* BeanContextBuilder */
2399   public RestClientBuilder beanFiltersRemove(Class<?>...values) {
2400      super.beanFiltersRemove(values);
2401      return this;
2402   }
2403
2404   @Override /* BeanContextBuilder */
2405   public RestClientBuilder beanFiltersRemove(Object...values) {
2406      super.beanFiltersRemove(values);
2407      return this;
2408   }
2409
2410   @Override /* BeanContextBuilder */
2411   public RestClientBuilder beanMapPutReturnsOldValue(boolean value) {
2412      super.beanMapPutReturnsOldValue(value);
2413      return this;
2414   }
2415
2416   @Override /* BeanContextBuilder */
2417   public RestClientBuilder beanMapPutReturnsOldValue() {
2418      super.beanMapPutReturnsOldValue();
2419      return this;
2420   }
2421
2422   @Override /* BeanContextBuilder */
2423   public RestClientBuilder beanMethodVisibility(Visibility value) {
2424      super.beanMethodVisibility(value);
2425      return this;
2426   }
2427
2428   @Override /* BeanContextBuilder */
2429   public RestClientBuilder beansRequireDefaultConstructor(boolean value) {
2430      super.beansRequireDefaultConstructor(value);
2431      return this;
2432   }
2433
2434   @Override /* BeanContextBuilder */
2435   public RestClientBuilder beansRequireDefaultConstructor() {
2436      super.beansRequireDefaultConstructor();
2437      return this;
2438   }
2439
2440   @Override /* BeanContextBuilder */
2441   public RestClientBuilder beansRequireSerializable(boolean value) {
2442      super.beansRequireSerializable(value);
2443      return this;
2444   }
2445
2446   @Override /* BeanContextBuilder */
2447   public RestClientBuilder beansRequireSerializable() {
2448      super.beansRequireSerializable();
2449      return this;
2450   }
2451
2452   @Override /* BeanContextBuilder */
2453   public RestClientBuilder beansRequireSettersForGetters(boolean value) {
2454      super.beansRequireSettersForGetters(value);
2455      return this;
2456   }
2457
2458   @Override /* BeanContextBuilder */
2459   public RestClientBuilder beansRequireSettersForGetters() {
2460      super.beansRequireSettersForGetters();
2461      return this;
2462   }
2463
2464   @Override /* BeanContextBuilder */
2465   public RestClientBuilder beansRequireSomeProperties(boolean value) {
2466      super.beansRequireSomeProperties(value);
2467      return this;
2468   }
2469
2470   @Override /* BeanContextBuilder */
2471   public RestClientBuilder beanTypePropertyName(String value) {
2472      super.beanTypePropertyName(value);
2473      return this;
2474   }
2475
2476   @Override /* BeanContextBuilder */
2477   public RestClientBuilder bpi(Class<?> beanClass, String value) {
2478      super.bpi(beanClass, value);
2479      return this;
2480   }
2481
2482   @Override /* BeanContextBuilder */
2483   public RestClientBuilder bpi(Map<String,String> values) {
2484      super.bpi(values);
2485      return this;
2486   }
2487
2488   @Override /* BeanContextBuilder */
2489   public RestClientBuilder bpi(String beanClassName, String value) {
2490      super.bpi(beanClassName, value);
2491      return this;
2492   }
2493
2494   @Override /* BeanContextBuilder */
2495   public RestClientBuilder bpx(Class<?> beanClass, String properties) {
2496      super.bpx(beanClass, properties);
2497      return this;
2498   }
2499
2500   @Override /* BeanContextBuilder */
2501   public RestClientBuilder bpx(Map<String,String> values) {
2502      super.bpx(values);
2503      return this;
2504   }
2505
2506   @Override /* BeanContextBuilder */
2507   public RestClientBuilder bpx(String beanClassName, String value) {
2508      super.bpx(beanClassName, value);
2509      return this;
2510   }
2511
2512   @Override /* BeanContextBuilder */
2513   public RestClientBuilder bpro(Class<?> beanClass, String value) {
2514      super.bpro(beanClass, value);
2515      return this;
2516   }
2517
2518   @Override /* BeanContextBuilder */
2519   public RestClientBuilder bpro(Map<String,String> values) {
2520      super.bpro(values);
2521      return this;
2522   }
2523
2524   @Override /* BeanContextBuilder */
2525   public RestClientBuilder bpro(String beanClassName, String value) {
2526      super.bpro(beanClassName, value);
2527      return this;
2528   }
2529
2530   @Override /* BeanContextBuilder */
2531   public RestClientBuilder bpwo(Class<?> beanClass, String properties) {
2532      super.bpwo(beanClass, properties);
2533      return this;
2534   }
2535
2536   @Override /* BeanContextBuilder */
2537   public RestClientBuilder bpwo(Map<String,String> values) {
2538      super.bpwo(values);
2539      return this;
2540   }
2541
2542   @Override /* BeanContextBuilder */
2543   public RestClientBuilder bpwo(String beanClassName, String value) {
2544      super.bpwo(beanClassName, value);
2545      return this;
2546   }
2547
2548   @Override /* BeanContextBuilder */
2549   public RestClientBuilder debug() {
2550      super.debug();
2551      return this;
2552   }
2553
2554   @Override /* BeanContextBuilder */
2555   public RestClientBuilder debug(boolean value) {
2556      super.debug(value);
2557      return this;
2558   }
2559
2560   @Override /* BeanContextBuilder */
2561   public RestClientBuilder dictionary(Class<?>...values) {
2562      super.dictionary(values);
2563      return this;
2564   }
2565
2566   @Override /* BeanContextBuilder */
2567   public RestClientBuilder dictionary(Object...values) {
2568      super.dictionary(values);
2569      return this;
2570   }
2571
2572   @Override /* BeanContextBuilder */
2573   public RestClientBuilder dictionaryReplace(Class<?>...values) {
2574      super.dictionaryReplace(values);
2575      return this;
2576   }
2577
2578   @Override /* BeanContextBuilder */
2579   public RestClientBuilder dictionaryReplace(Object...values) {
2580      super.dictionaryReplace(values);
2581      return this;
2582   }
2583
2584   @Override /* BeanContextBuilder */
2585   public RestClientBuilder dictionaryRemove(Class<?>...values) {
2586      super.dictionaryRemove(values);
2587      return this;
2588   }
2589
2590   @Override /* BeanContextBuilder */
2591   public RestClientBuilder dictionaryRemove(Object...values) {
2592      super.dictionaryRemove(values);
2593      return this;
2594   }
2595
2596   @Override /* BeanContextBuilder */
2597   public <T> RestClientBuilder example(Class<T> c, T o) {
2598      super.example(c, o);
2599      return this;
2600   }
2601
2602   @Override /* BeanContextBuilder */
2603   public <T> RestClientBuilder exampleJson(Class<T> c, String value) {
2604      super.exampleJson(c, value);
2605      return this;
2606   }
2607
2608   @Override /* BeanContextBuilder */
2609   public RestClientBuilder ignoreInvocationExceptionsOnGetters(boolean value) {
2610      super.ignoreInvocationExceptionsOnGetters(value);
2611      return this;
2612   }
2613
2614   @Override /* BeanContextBuilder */
2615   public RestClientBuilder ignoreInvocationExceptionsOnGetters() {
2616      super.ignoreInvocationExceptionsOnGetters();
2617      return this;
2618   }
2619
2620   @Override /* BeanContextBuilder */
2621   public RestClientBuilder ignoreInvocationExceptionsOnSetters(boolean value) {
2622      super.ignoreInvocationExceptionsOnSetters(value);
2623      return this;
2624   }
2625
2626   @Override /* BeanContextBuilder */
2627   public RestClientBuilder ignoreInvocationExceptionsOnSetters() {
2628      super.ignoreInvocationExceptionsOnSetters();
2629      return this;
2630   }
2631
2632   @Override /* BeanContextBuilder */
2633   public RestClientBuilder ignorePropertiesWithoutSetters(boolean value) {
2634      super.ignorePropertiesWithoutSetters(value);
2635      return this;
2636   }
2637
2638   @Override /* BeanContextBuilder */
2639   public RestClientBuilder ignoreUnknownBeanProperties(boolean value) {
2640      super.ignoreUnknownBeanProperties(value);
2641      return this;
2642   }
2643
2644   @Override /* BeanContextBuilder */
2645   public RestClientBuilder ignoreUnknownBeanProperties() {
2646      super.ignoreUnknownBeanProperties();
2647      return this;
2648   }
2649
2650   @Override /* BeanContextBuilder */
2651   public RestClientBuilder ignoreUnknownNullBeanProperties(boolean value) {
2652      super.ignoreUnknownNullBeanProperties(value);
2653      return this;
2654   }
2655
2656   @Override /* BeanContextBuilder */
2657   public RestClientBuilder implClass(Class<?> interfaceClass, Class<?> implClass) {
2658      super.implClass(interfaceClass, implClass);
2659      return this;
2660   }
2661
2662   @Override /* BeanContextBuilder */
2663   public RestClientBuilder implClasses(Map<String,Class<?>> values) {
2664      super.implClasses(values);
2665      return this;
2666   }
2667
2668   @Override /* BeanContextBuilder */
2669   public RestClientBuilder locale(Locale value) {
2670      super.locale(value);
2671      return this;
2672   }
2673
2674   @Override /* BeanContextBuilder */
2675   public RestClientBuilder mediaType(MediaType value) {
2676      super.mediaType(value);
2677      return this;
2678   }
2679
2680   @Override /* BeanContextBuilder */
2681   public RestClientBuilder notBeanClasses(Class<?>...values) {
2682      super.notBeanClasses(values);
2683      return this;
2684   }
2685
2686   @Override /* BeanContextBuilder */
2687   public RestClientBuilder notBeanClasses(Object...values) {
2688      super.notBeanClasses(values);
2689      return this;
2690   }
2691
2692   @Override /* BeanContextBuilder */
2693   public RestClientBuilder notBeanClassesReplace(Class<?>...values) {
2694      super.notBeanClassesReplace(values);
2695      return this;
2696   }
2697
2698   @Override /* BeanContextBuilder */
2699   public RestClientBuilder notBeanClassesReplace(Object...values) {
2700      super.notBeanClassesReplace(values);
2701      return this;
2702   }
2703
2704   @Override /* BeanContextBuilder */
2705   public RestClientBuilder notBeanClassesRemove(Class<?>...values) {
2706      super.notBeanClassesRemove(values);
2707      return this;
2708   }
2709
2710   @Override /* BeanContextBuilder */
2711   public RestClientBuilder notBeanClassesRemove(Object...values) {
2712      super.notBeanClassesRemove(values);
2713      return this;
2714   }
2715
2716   @Override /* BeanContextBuilder */
2717   public RestClientBuilder notBeanPackages(Object...values) {
2718      super.notBeanPackages(values);
2719      return this;
2720   }
2721
2722   @Override /* BeanContextBuilder */
2723   public RestClientBuilder notBeanPackages(String...values) {
2724      super.notBeanPackages(values);
2725      return this;
2726   }
2727
2728   @Override /* BeanContextBuilder */
2729   public RestClientBuilder notBeanPackagesReplace(String...values) {
2730      super.notBeanPackagesReplace(values);
2731      return this;
2732   }
2733
2734   @Override /* BeanContextBuilder */
2735   public RestClientBuilder notBeanPackagesReplace(Object...values) {
2736      super.notBeanPackagesReplace(values);
2737      return this;
2738   }
2739
2740   @Override /* BeanContextBuilder */
2741   public RestClientBuilder notBeanPackagesRemove(String...values) {
2742      super.notBeanPackagesRemove(values);
2743      return this;
2744   }
2745
2746   @Override /* BeanContextBuilder */
2747   public RestClientBuilder notBeanPackagesRemove(Object...values) {
2748      super.notBeanPackagesRemove(values);
2749      return this;
2750   }
2751
2752   @Override /* BeanContextBuilder */
2753   public RestClientBuilder pojoSwaps(Class<?>...values) {
2754      super.pojoSwaps(values);
2755      return this;
2756   }
2757
2758   @Override /* BeanContextBuilder */
2759   public RestClientBuilder pojoSwaps(Object...values) {
2760      super.pojoSwaps(values);
2761      return this;
2762   }
2763
2764   @Override /* BeanContextBuilder */
2765   public RestClientBuilder pojoSwapsReplace(Class<?>...values) {
2766      super.pojoSwapsReplace(values);
2767      return this;
2768   }
2769
2770   @Override /* BeanContextBuilder */
2771   public RestClientBuilder pojoSwapsReplace(Object...values) {
2772      super.pojoSwapsReplace(values);
2773      return this;
2774   }
2775
2776   @Override /* BeanContextBuilder */
2777   public RestClientBuilder pojoSwapsRemove(Class<?>...values) {
2778      super.pojoSwapsRemove(values);
2779      return this;
2780   }
2781
2782   @Override /* BeanContextBuilder */
2783   public RestClientBuilder pojoSwapsRemove(Object...values) {
2784      super.pojoSwapsRemove(values);
2785      return this;
2786   }
2787
2788   @Override /* BeanContextBuilder */
2789   public RestClientBuilder sortProperties(boolean value) {
2790      super.sortProperties(value);
2791      return this;
2792   }
2793
2794   @Override /* BeanContextBuilder */
2795   public RestClientBuilder sortProperties() {
2796      super.sortProperties();
2797      return this;
2798   }
2799
2800   @Override /* BeanContextBuilder */
2801   public RestClientBuilder timeZone(TimeZone value) {
2802      super.timeZone(value);
2803      return this;
2804   }
2805
2806   @Override /* BeanContextBuilder */
2807   public RestClientBuilder useEnumNames(boolean value) {
2808      super.useEnumNames(value);
2809      return this;
2810   }
2811
2812   @Override /* BeanContextBuilder */
2813   public RestClientBuilder useEnumNames() {
2814      super.useEnumNames();
2815      return this;
2816   }
2817
2818   @Override /* BeanContextBuilder */
2819   public RestClientBuilder useInterfaceProxies(boolean value) {
2820      super.useInterfaceProxies(value);
2821      return this;
2822   }
2823
2824   @Override /* BeanContextBuilder */
2825   public RestClientBuilder useJavaBeanIntrospector(boolean value) {
2826      super.useJavaBeanIntrospector(value);
2827      return this;
2828   }
2829
2830   @Override /* BeanContextBuilder */
2831   public RestClientBuilder useJavaBeanIntrospector() {
2832      super.useJavaBeanIntrospector();
2833      return this;
2834   }
2835
2836   @Override /* ContextBuilder */
2837   public RestClientBuilder annotations(Annotation...values) {
2838      super.annotations(values);
2839      return this;
2840   }
2841
2842   @Override /* ContextBuilder */
2843   public RestClientBuilder set(String name, Object value) {
2844      super.set(name, value);
2845      return this;
2846   }
2847
2848   @Override /* ContextBuilder */
2849   public RestClientBuilder set(Map<String,Object> properties) {
2850      super.set(properties);
2851      return this;
2852   }
2853
2854   @Override /* ContextBuilder */
2855   public RestClientBuilder add(Map<String,Object> properties) {
2856      super.add(properties);
2857      return this;
2858   }
2859
2860   @Override /* ContextBuilder */
2861   public RestClientBuilder addTo(String name, Object value) {
2862      super.addTo(name, value);
2863      return this;
2864   }
2865
2866   @Override /* ContextBuilder */
2867   public RestClientBuilder addTo(String name, String key, Object value) {
2868      super.addTo(name, key, value);
2869      return this;
2870   }
2871
2872   @Override /* ContextBuilder */
2873   public RestClientBuilder removeFrom(String name, Object value) {
2874      super.removeFrom(name, value);
2875      return this;
2876   }
2877
2878   @Override /* ContextBuilder */
2879   public RestClientBuilder apply(PropertyStore copyFrom) {
2880      super.apply(copyFrom);
2881      return this;
2882   }
2883
2884   @Override /* ContextBuilder */
2885   public RestClientBuilder applyAnnotations(AnnotationList al, VarResolverSession vrs) {
2886      super.applyAnnotations(al, vrs);
2887      return this;
2888   }
2889
2890   @Override /* ContextBuilder */
2891   public RestClientBuilder applyAnnotations(Class<?>...fromClasses) {
2892      super.applyAnnotations(fromClasses);
2893      return this;
2894   }
2895
2896   @Override /* ContextBuilder */
2897   public RestClientBuilder applyAnnotations(Method...fromMethods) {
2898      super.applyAnnotations(fromMethods);
2899      return this;
2900   }
2901
2902   //------------------------------------------------------------------------------------------------
2903   // Passthrough methods for HttpClientBuilder.
2904   //------------------------------------------------------------------------------------------------
2905
2906   /**
2907    * @return This object (for method chaining).
2908    * @see HttpClientBuilder#disableRedirectHandling()
2909    */
2910   public RestClientBuilder disableRedirectHandling() {
2911      httpClientBuilder.disableRedirectHandling();
2912      return this;
2913   }
2914
2915   /**
2916    * @param redirectStrategy New property value.
2917    * @return This object (for method chaining).
2918    * @see HttpClientBuilder#setRedirectStrategy(RedirectStrategy)
2919    */
2920   public RestClientBuilder redirectStrategy(RedirectStrategy redirectStrategy) {
2921      httpClientBuilder.setRedirectStrategy(redirectStrategy);
2922      return this;
2923   }
2924
2925   /**
2926    * @param cookieSpecRegistry New property value.
2927    * @return This object (for method chaining).
2928    * @see HttpClientBuilder#setDefaultCookieSpecRegistry(Lookup)
2929    */
2930   public RestClientBuilder defaultCookieSpecRegistry(Lookup<CookieSpecProvider> cookieSpecRegistry) {
2931      httpClientBuilder.setDefaultCookieSpecRegistry(cookieSpecRegistry);
2932      return this;
2933   }
2934
2935   /**
2936    * @param requestExec New property value.
2937    * @return This object (for method chaining).
2938    * @see HttpClientBuilder#setRequestExecutor(HttpRequestExecutor)
2939    */
2940   public RestClientBuilder requestExecutor(HttpRequestExecutor requestExec) {
2941      httpClientBuilder.setRequestExecutor(requestExec);
2942      return this;
2943   }
2944
2945   /**
2946    * @param hostnameVerifier New property value.
2947    * @return This object (for method chaining).
2948    * @see HttpClientBuilder#setSSLHostnameVerifier(HostnameVerifier)
2949    */
2950   public RestClientBuilder sslHostnameVerifier(HostnameVerifier hostnameVerifier) {
2951      httpClientBuilder.setSSLHostnameVerifier(hostnameVerifier);
2952      return this;
2953   }
2954
2955   /**
2956    * @param publicSuffixMatcher New property value.
2957    * @return This object (for method chaining).
2958    * @see HttpClientBuilder#setPublicSuffixMatcher(PublicSuffixMatcher)
2959    */
2960   public RestClientBuilder publicSuffixMatcher(PublicSuffixMatcher publicSuffixMatcher) {
2961      httpClientBuilder.setPublicSuffixMatcher(publicSuffixMatcher);
2962      return this;
2963   }
2964
2965   /**
2966    * @param sslContext New property value.
2967    * @return This object (for method chaining).
2968    * @see HttpClientBuilder#setSSLContext(SSLContext)
2969    */
2970   public RestClientBuilder sslContext(SSLContext sslContext) {
2971      httpClientBuilder.setSSLContext(sslContext);
2972      return this;
2973   }
2974
2975   /**
2976    * @param sslSocketFactory New property value.
2977    * @return This object (for method chaining).
2978    * @see HttpClientBuilder#setSSLSocketFactory(LayeredConnectionSocketFactory)
2979    */
2980   public RestClientBuilder sslSocketFactory(LayeredConnectionSocketFactory sslSocketFactory) {
2981      httpClientBuilder.setSSLSocketFactory(sslSocketFactory);
2982      return this;
2983   }
2984
2985   /**
2986    * @param maxConnTotal New property value.
2987    * @return This object (for method chaining).
2988    * @see HttpClientBuilder#setMaxConnTotal(int)
2989    */
2990   public RestClientBuilder maxConnTotal(int maxConnTotal) {
2991      httpClientBuilder.setMaxConnTotal(maxConnTotal);
2992      return this;
2993   }
2994
2995   /**
2996    * @param maxConnPerRoute New property value.
2997    * @return This object (for method chaining).
2998    * @see HttpClientBuilder#setMaxConnPerRoute(int)
2999    */
3000   public RestClientBuilder maxConnPerRoute(int maxConnPerRoute) {
3001      httpClientBuilder.setMaxConnPerRoute(maxConnPerRoute);
3002      return this;
3003   }
3004
3005   /**
3006    * @param config New property value.
3007    * @return This object (for method chaining).
3008    * @see HttpClientBuilder#setDefaultSocketConfig(SocketConfig)
3009    */
3010   public RestClientBuilder defaultSocketConfig(SocketConfig config) {
3011      httpClientBuilder.setDefaultSocketConfig(config);
3012      return this;
3013   }
3014
3015   /**
3016    * @param config New property value.
3017    * @return This object (for method chaining).
3018    * @see HttpClientBuilder#setDefaultConnectionConfig(ConnectionConfig)
3019    */
3020   public RestClientBuilder defaultConnectionConfig(ConnectionConfig config) {
3021      httpClientBuilder.setDefaultConnectionConfig(config);
3022      return this;
3023   }
3024
3025   /**
3026    * @param connTimeToLive New property value.
3027    * @param connTimeToLiveTimeUnit New property value.
3028    * @return This object (for method chaining).
3029    * @see HttpClientBuilder#setConnectionTimeToLive(long,TimeUnit)
3030    */
3031   public RestClientBuilder connectionTimeToLive(long connTimeToLive, TimeUnit connTimeToLiveTimeUnit) {
3032      httpClientBuilder.setConnectionTimeToLive(connTimeToLive, connTimeToLiveTimeUnit);
3033      return this;
3034   }
3035
3036   /**
3037    * @param connManager New property value.
3038    * @return This object (for method chaining).
3039    * @see HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)
3040    */
3041   public RestClientBuilder connectionManager(HttpClientConnectionManager connManager) {
3042      this.httpClientConnectionManager = connManager;
3043      httpClientBuilder.setConnectionManager(connManager);
3044      return this;
3045   }
3046
3047   /**
3048    * @param shared New property value.
3049    * @return This object (for method chaining).
3050    * @see HttpClientBuilder#setConnectionManagerShared(boolean)
3051    */
3052   public RestClientBuilder connectionManagerShared(boolean shared) {
3053      httpClientBuilder.setConnectionManagerShared(shared);
3054      return this;
3055   }
3056
3057   /**
3058    * @param reuseStrategy New property value.
3059    * @return This object (for method chaining).
3060    * @see HttpClientBuilder#setConnectionReuseStrategy(ConnectionReuseStrategy)
3061    */
3062   public RestClientBuilder connectionReuseStrategy(ConnectionReuseStrategy reuseStrategy) {
3063      httpClientBuilder.setConnectionReuseStrategy(reuseStrategy);
3064      return this;
3065   }
3066
3067   /**
3068    * @param keepAliveStrategy New property value.
3069    * @return This object (for method chaining).
3070    * @see HttpClientBuilder#setKeepAliveStrategy(ConnectionKeepAliveStrategy)
3071    */
3072   public RestClientBuilder keepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy) {
3073      httpClientBuilder.setKeepAliveStrategy(keepAliveStrategy);
3074      return this;
3075   }
3076
3077   /**
3078    * @param targetAuthStrategy New property value.
3079    * @return This object (for method chaining).
3080    * @see HttpClientBuilder#setTargetAuthenticationStrategy(AuthenticationStrategy)
3081    */
3082   public RestClientBuilder targetAuthenticationStrategy(AuthenticationStrategy targetAuthStrategy) {
3083      httpClientBuilder.setTargetAuthenticationStrategy(targetAuthStrategy);
3084      return this;
3085   }
3086
3087   /**
3088    * @param proxyAuthStrategy New property value.
3089    * @return This object (for method chaining).
3090    * @see HttpClientBuilder#setProxyAuthenticationStrategy(AuthenticationStrategy)
3091    */
3092   public RestClientBuilder proxyAuthenticationStrategy(AuthenticationStrategy proxyAuthStrategy) {
3093      httpClientBuilder.setProxyAuthenticationStrategy(proxyAuthStrategy);
3094      return this;
3095   }
3096
3097   /**
3098    * @param userTokenHandler New property value.
3099    * @return This object (for method chaining).
3100    * @see HttpClientBuilder#setUserTokenHandler(UserTokenHandler)
3101    */
3102   public RestClientBuilder userTokenHandler(UserTokenHandler userTokenHandler) {
3103      httpClientBuilder.setUserTokenHandler(userTokenHandler);
3104      return this;
3105   }
3106
3107   /**
3108    * @return This object (for method chaining).
3109    * @see HttpClientBuilder#disableConnectionState()
3110    */
3111   public RestClientBuilder disableConnectionState() {
3112      httpClientBuilder.disableConnectionState();
3113      return this;
3114   }
3115
3116   /**
3117    * @param schemePortResolver New property value.
3118    * @return This object (for method chaining).
3119    * @see HttpClientBuilder#setSchemePortResolver(SchemePortResolver)
3120    */
3121   public RestClientBuilder schemePortResolver(SchemePortResolver schemePortResolver) {
3122      httpClientBuilder.setSchemePortResolver(schemePortResolver);
3123      return this;
3124   }
3125
3126   /**
3127    * @param userAgent New property value.
3128    * @return This object (for method chaining).
3129    * @see HttpClientBuilder#setUserAgent(String)
3130    */
3131   public RestClientBuilder userAgent(String userAgent) {
3132      httpClientBuilder.setUserAgent(userAgent);
3133      return this;
3134   }
3135
3136   /**
3137    * @param defaultHeaders New property value.
3138    * @return This object (for method chaining).
3139    * @see HttpClientBuilder#setDefaultHeaders(Collection)
3140    */
3141   public RestClientBuilder defaultHeaders(Collection<? extends Header> defaultHeaders) {
3142      httpClientBuilder.setDefaultHeaders(defaultHeaders);
3143      return this;
3144   }
3145
3146   /**
3147    * @param itcp New property value.
3148    * @return This object (for method chaining).
3149    * @see HttpClientBuilder#addInterceptorFirst(HttpResponseInterceptor)
3150    */
3151   public RestClientBuilder addInterceptorFirst(HttpResponseInterceptor itcp) {
3152      httpClientBuilder.addInterceptorFirst(itcp);
3153      return this;
3154   }
3155
3156   /**
3157    * @param itcp New property value.
3158    * @return This object (for method chaining).
3159    * @see HttpClientBuilder#addInterceptorLast(HttpResponseInterceptor)
3160    */
3161   public RestClientBuilder addInterceptorLast(HttpResponseInterceptor itcp) {
3162      httpClientBuilder.addInterceptorLast(itcp);
3163      return this;
3164   }
3165
3166   /**
3167    * @param itcp New property value.
3168    * @return This object (for method chaining).
3169    * @see HttpClientBuilder#addInterceptorFirst(HttpRequestInterceptor)
3170    */
3171   public RestClientBuilder addInterceptorFirst(HttpRequestInterceptor itcp) {
3172      httpClientBuilder.addInterceptorFirst(itcp);
3173      return this;
3174   }
3175
3176   /**
3177    * @param itcp New property value.
3178    * @return This object (for method chaining).
3179    * @see HttpClientBuilder#addInterceptorLast(HttpRequestInterceptor)
3180    */
3181   public RestClientBuilder addInterceptorLast(HttpRequestInterceptor itcp) {
3182      httpClientBuilder.addInterceptorLast(itcp);
3183      return this;
3184   }
3185
3186   /**
3187    * @return This object (for method chaining).
3188    * @see HttpClientBuilder#disableCookieManagement()
3189    */
3190   public RestClientBuilder disableCookieManagement() {
3191      httpClientBuilder.disableCookieManagement();
3192      return this;
3193   }
3194
3195   /**
3196    * @return This object (for method chaining).
3197    * @see HttpClientBuilder#disableContentCompression()
3198    */
3199   public RestClientBuilder disableContentCompression() {
3200      httpClientBuilder.disableContentCompression();
3201      return this;
3202   }
3203
3204   /**
3205    * @return This object (for method chaining).
3206    * @see HttpClientBuilder#disableAuthCaching()
3207    */
3208   public RestClientBuilder disableAuthCaching() {
3209      httpClientBuilder.disableAuthCaching();
3210      return this;
3211   }
3212
3213   /**
3214    * @param httpprocessor New property value.
3215    * @return This object (for method chaining).
3216    * @see HttpClientBuilder#setHttpProcessor(HttpProcessor)
3217    */
3218   public RestClientBuilder httpProcessor(HttpProcessor httpprocessor) {
3219      httpClientBuilder.setHttpProcessor(httpprocessor);
3220      return this;
3221   }
3222
3223   /**
3224    * @param retryHandler New property value.
3225    * @return This object (for method chaining).
3226    * @see HttpClientBuilder#setRetryHandler(HttpRequestRetryHandler)
3227    */
3228   public RestClientBuilder retryHandler(HttpRequestRetryHandler retryHandler) {
3229      httpClientBuilder.setRetryHandler(retryHandler);
3230      return this;
3231   }
3232
3233   /**
3234    * @return This object (for method chaining).
3235    * @see HttpClientBuilder#disableAutomaticRetries()
3236    */
3237   public RestClientBuilder disableAutomaticRetries() {
3238      httpClientBuilder.disableAutomaticRetries();
3239      return this;
3240   }
3241
3242   /**
3243    * @param proxy New property value.
3244    * @return This object (for method chaining).
3245    * @see HttpClientBuilder#setProxy(HttpHost)
3246    */
3247   public RestClientBuilder proxy(HttpHost proxy) {
3248      httpClientBuilder.setProxy(proxy);
3249      return this;
3250   }
3251
3252   /**
3253    * @param routePlanner New property value.
3254    * @return This object (for method chaining).
3255    * @see HttpClientBuilder#setRoutePlanner(HttpRoutePlanner)
3256    */
3257   public RestClientBuilder routePlanner(HttpRoutePlanner routePlanner) {
3258      httpClientBuilder.setRoutePlanner(routePlanner);
3259      return this;
3260   }
3261
3262   /**
3263    * @param connectionBackoffStrategy New property value.
3264    * @return This object (for method chaining).
3265    * @see HttpClientBuilder#setConnectionBackoffStrategy(ConnectionBackoffStrategy)
3266    */
3267   public RestClientBuilder connectionBackoffStrategy(ConnectionBackoffStrategy connectionBackoffStrategy) {
3268      httpClientBuilder.setConnectionBackoffStrategy(connectionBackoffStrategy);
3269      return this;
3270   }
3271
3272   /**
3273    * @param backoffManager New property value.
3274    * @return This object (for method chaining).
3275    * @see HttpClientBuilder#setBackoffManager(BackoffManager)
3276    */
3277   public RestClientBuilder backoffManager(BackoffManager backoffManager) {
3278      httpClientBuilder.setBackoffManager(backoffManager);
3279      return this;
3280   }
3281
3282   /**
3283    * @param serviceUnavailStrategy New property value.
3284    * @return This object (for method chaining).
3285    * @see HttpClientBuilder#setServiceUnavailableRetryStrategy(ServiceUnavailableRetryStrategy)
3286    */
3287   public RestClientBuilder serviceUnavailableRetryStrategy(ServiceUnavailableRetryStrategy serviceUnavailStrategy) {
3288      httpClientBuilder.setServiceUnavailableRetryStrategy(serviceUnavailStrategy);
3289      return this;
3290   }
3291
3292   /**
3293    * @param cookieStore New property value.
3294    * @return This object (for method chaining).
3295    * @see HttpClientBuilder#setDefaultCookieStore(CookieStore)
3296    */
3297   public RestClientBuilder defaultCookieStore(CookieStore cookieStore) {
3298      httpClientBuilder.setDefaultCookieStore(cookieStore);
3299      return this;
3300   }
3301
3302   /**
3303    * @param credentialsProvider New property value.
3304    * @return This object (for method chaining).
3305    * @see HttpClientBuilder#setDefaultCredentialsProvider(CredentialsProvider)
3306    */
3307   public RestClientBuilder defaultCredentialsProvider(CredentialsProvider credentialsProvider) {
3308      httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
3309      return this;
3310   }
3311
3312   /**
3313    * @param authSchemeRegistry New property value.
3314    * @return This object (for method chaining).
3315    * @see HttpClientBuilder#setDefaultAuthSchemeRegistry(Lookup)
3316    */
3317   public RestClientBuilder defaultAuthSchemeRegistry(Lookup<AuthSchemeProvider> authSchemeRegistry) {
3318      httpClientBuilder.setDefaultAuthSchemeRegistry(authSchemeRegistry);
3319      return this;
3320   }
3321
3322   /**
3323    * @param contentDecoderMap New property value.
3324    * @return This object (for method chaining).
3325    * @see HttpClientBuilder#setContentDecoderRegistry(Map)
3326    */
3327   public RestClientBuilder contentDecoderRegistry(Map<String,InputStreamFactory> contentDecoderMap) {
3328      httpClientBuilder.setContentDecoderRegistry(contentDecoderMap);
3329      return this;
3330   }
3331
3332   /**
3333    * @param config New property value.
3334    * @return This object (for method chaining).
3335    * @see HttpClientBuilder#setDefaultRequestConfig(RequestConfig)
3336    */
3337   public RestClientBuilder defaultRequestConfig(RequestConfig config) {
3338      httpClientBuilder.setDefaultRequestConfig(config);
3339      return this;
3340   }
3341
3342   /**
3343    * @return This object (for method chaining).
3344    * @see HttpClientBuilder#useSystemProperties()
3345    */
3346   public RestClientBuilder useSystemProperties() {
3347      httpClientBuilder.useSystemProperties();
3348      return this;
3349   }
3350
3351   /**
3352    * @return This object (for method chaining).
3353    * @see HttpClientBuilder#evictExpiredConnections()
3354    */
3355   public RestClientBuilder evictExpiredConnections() {
3356      httpClientBuilder.evictExpiredConnections();
3357      return this;
3358   }
3359
3360   /**
3361    * @param maxIdleTime New property value.
3362    * @param maxIdleTimeUnit New property value.
3363    * @return This object (for method chaining).
3364    * @see HttpClientBuilder#evictIdleConnections(long,TimeUnit)
3365    */
3366   public RestClientBuilder evictIdleConnections(long maxIdleTime, TimeUnit maxIdleTimeUnit) {
3367      httpClientBuilder.evictIdleConnections(maxIdleTime, maxIdleTimeUnit);
3368      return this;
3369   }
3370}