3737 * Implementation is not thread-safe.
3838 * </p>
3939 *
40+ * <p>
41+ * Upgrade warning: prior to version 1.10 there was a {@code builder} method in
42+ * {@link JsonHttpClient}, this has been removed in version 1.10. The Builder can now be
43+ * instantiated with
44+ * {@link Builder#Builder(HttpTransport, JsonFactory, String, String, HttpRequestInitializer)}.
45+ * </p>
46+ *
4047 * @since 1.6
4148 * @author Ravi Mistry
4249 */
@@ -240,14 +247,14 @@ protected void initialize(JsonHttpRequest jsonHttpRequest) throws IOException {
240247 * Constructor with required parameters.
241248 *
242249 * <p>
243- * Use {@link #builder } if you need to specify any of the optional parameters.
250+ * Use {@link Builder } if you need to specify any of the optional parameters.
244251 * </p>
245252 *
246253 * @param transport The transport to use for requests
247254 * @param jsonFactory A factory for creating JSON parsers and serializers
248255 * @param baseUrl The base URL of the service. Must end with a "/"
249- * @deprecated (scheduled to be removed in 1.11) Use
250- * {@link #JsonHttpClient(HttpTransport, JsonFactory, String, String)}.
256+ * @deprecated (scheduled to be removed in 1.11) Use {@link #JsonHttpClient(HttpTransport,
257+ * JsonFactory, String, String, HttpRequestInitializer )}.
251258 */
252259 @ Deprecated
253260 public JsonHttpClient (HttpTransport transport , JsonFactory jsonFactory , String baseUrl ) {
@@ -258,19 +265,20 @@ public JsonHttpClient(HttpTransport transport, JsonFactory jsonFactory, String b
258265 * Constructor with required parameters.
259266 *
260267 * <p>
261- * Use {@link #builder } if you need to specify any of the optional parameters.
268+ * Use {@link Builder } if you need to specify any of the optional parameters.
262269 * </p>
263270 *
264271 * @param transport The transport to use for requests
265272 * @param jsonFactory A factory for creating JSON parsers and serializers
266273 * @param rootUrl The root URL of the service. Must end with a "/"
267274 * @param servicePath The service path of the service. Must end with a "/" and not begin with a
268275 * "/". It is allowed to be an empty string {@code ""}
276+ * @param httpRequestInitializer The HTTP request initializer or {@code null} for none
269277 * @since 1.10
270278 */
271- public JsonHttpClient (
272- HttpTransport transport , JsonFactory jsonFactory , String rootUrl , String servicePath ) {
273- this (transport , null , null , jsonFactory , null , rootUrl , servicePath , null );
279+ public JsonHttpClient (HttpTransport transport , JsonFactory jsonFactory , String rootUrl ,
280+ String servicePath , HttpRequestInitializer httpRequestInitializer ) {
281+ this (transport , null , httpRequestInitializer , jsonFactory , null , rootUrl , servicePath , null );
274282 }
275283
276284 /**
@@ -513,36 +521,6 @@ protected InputStream executeAsInputStream(HttpMethod method, GenericUrl url, Ob
513521 return response .getContent ();
514522 }
515523
516- /**
517- * Returns an instance of a new builder.
518- *
519- * @param transport The transport to use for requests
520- * @param jsonFactory A factory for creating JSON parsers and serializers
521- * @param baseUrl The base URL of the service. Must end with a "/"
522- * @deprecated (scheduled to be removed in 1.11) Use
523- * {@link #builder(HttpTransport, JsonFactory, GenericUrl, String)} instead.
524- */
525- @ Deprecated
526- public static Builder builder (
527- HttpTransport transport , JsonFactory jsonFactory , GenericUrl baseUrl ) {
528- return new Builder (transport , jsonFactory , baseUrl );
529- }
530-
531- /**
532- * Returns an instance of a new builder.
533- *
534- * @param transport The transport to use for requests
535- * @param jsonFactory A factory for creating JSON parsers and serializers
536- * @param rootUrl The root URL of the service. Must end with a "/"
537- * @param servicePath The service path of the service. Must end with a "/" and not begin with a
538- * "/". It is allowed to be an empty string {@code ""}
539- * @since 1.10
540- */
541- public static Builder builder (
542- HttpTransport transport , JsonFactory jsonFactory , GenericUrl rootUrl , String servicePath ) {
543- return new Builder (transport , jsonFactory , rootUrl , servicePath );
544- }
545-
546524 /**
547525 * Builder for {@link JsonHttpClient}.
548526 *
@@ -578,7 +556,7 @@ public static class Builder {
578556 private GenericUrl baseUrl ;
579557
580558 /** The root URL of the service, for example {@code "https://www.googleapis.com/"}. */
581- private GenericUrl rootUrl ;
559+ private String rootUrl ;
582560
583561 /** The service path of the service, for example {@code "tasks/v1/"}. */
584562 private String servicePath ;
@@ -602,8 +580,8 @@ public static class Builder {
602580 * @param jsonFactory A factory for creating JSON parsers and serializers
603581 * @param baseUrl The base URL of the service. Must end with a "/"
604582 *
605- * @deprecated (scheduled to be removed in 1.11) Use
606- * {@link #Builder(HttpTransport, JsonFactory, GenericUrl, String )} instead.
583+ * @deprecated (scheduled to be removed in 1.11) Use {@link #Builder(HttpTransport, JsonFactory,
584+ * String, String, HttpRequestInitializer )} instead.
607585 */
608586 @ Deprecated
609587 protected Builder (HttpTransport transport , JsonFactory jsonFactory , GenericUrl baseUrl ) {
@@ -621,14 +599,17 @@ protected Builder(HttpTransport transport, JsonFactory jsonFactory, GenericUrl b
621599 * @param rootUrl The root URL of the service. Must end with a "/"
622600 * @param servicePath The service path of the service. Must end with a "/" and not begin with a
623601 * "/". It is allowed to be an empty string {@code ""}
602+ * @param httpRequestInitializer The HTTP request initializer or {@code null} for none
624603 * @since 1.10
625604 */
626- protected Builder (
627- HttpTransport transport , JsonFactory jsonFactory , GenericUrl rootUrl , String servicePath ) {
605+ public Builder (HttpTransport transport , JsonFactory jsonFactory , String rootUrl ,
606+ String servicePath ,
607+ HttpRequestInitializer httpRequestInitializer ) {
628608 this .transport = transport ;
629609 this .jsonFactory = jsonFactory ;
630610 setRootUrl (rootUrl );
631611 setServicePath (servicePath );
612+ this .httpRequestInitializer = httpRequestInitializer ;
632613 }
633614
634615 /**
@@ -652,13 +633,13 @@ public JsonHttpClient build() {
652633 httpRequestInitializer ,
653634 jsonFactory ,
654635 jsonObjectParser ,
655- rootUrl . build () ,
636+ rootUrl ,
656637 servicePath ,
657638 applicationName );
658639 }
659640
660641 /**
661- * Returns if baseUrl is used instead of {@code servicePath } and {@code rootUrl }.
642+ * Returns if {@code baseUrl} is used instead of {@code rootUrl } and {@code servicePath }.
662643 *
663644 * @since 1.10
664645 * @deprecated (scheduled to be removed in 1.11) Use {@link #getRootUrl} and
@@ -714,7 +695,8 @@ public Builder setObjectParser(JsonObjectParser parser) {
714695 * This is determined when the library is generated and normally should not be changed.
715696 *
716697 * <p>
717- * Use this method only if {@link #builder(HttpTransport, JsonFactory, GenericUrl)} was used.
698+ * Use this method only if {@code baseUrl} is used instead of {@code rootUrl} and
699+ * {@code servicePath}.
718700 * </p>
719701 *
720702 * @deprecated (scheduled to be removed in 1.11) Use {@link #getRootUrl} and
@@ -732,7 +714,8 @@ public final GenericUrl getBaseUrl() {
732714 * and normally should not be changed. Subclasses should override by calling super.
733715 *
734716 * <p>
735- * Use this method only if {@link #builder(HttpTransport, JsonFactory, GenericUrl)} was used.
717+ * Use this method only if {@code baseUrl} is used instead of {@code rootUrl} and
718+ * {@code servicePath}.
736719 * </p>
737720 *
738721 * @since 1.7
@@ -752,15 +735,15 @@ public Builder setBaseUrl(GenericUrl baseUrl) {
752735 * URL-encoded and must end with a "/".
753736 *
754737 * <p>
755- * Use this method only if {@link #builder(HttpTransport, JsonFactory, GenericUrl, String)} was
756- * used .
738+ * Use this method only if {@code rootUrl} and {@code servicePath} are used instead of
739+ * {@code baseUrl} .
757740 * </p>
758741 *
759742 * @since 1.10
760743 */
761744 public final String getRootUrl () {
762745 Preconditions .checkArgument (!baseUrlUsed );
763- return rootUrl . build () ;
746+ return rootUrl ;
764747 }
765748
766749 /**
@@ -769,16 +752,16 @@ public final String getRootUrl() {
769752 * normally should be changed. Subclasses should override by calling super.
770753 *
771754 * <p>
772- * Use this method only if {@link #builder(HttpTransport, JsonFactory, GenericUrl, String)} was
773- * used .
755+ * Use this method only if {@code rootUrl} and {@code servicePath} are used instead of
756+ * {@code baseUrl} .
774757 * </p>
775758 *
776759 * @since 1.10
777760 */
778- public Builder setRootUrl (GenericUrl rootUrl ) {
761+ public Builder setRootUrl (String rootUrl ) {
779762 Preconditions .checkArgument (!baseUrlUsed );
780763 Preconditions .checkNotNull (rootUrl );
781- Preconditions .checkArgument (rootUrl .build (). endsWith ("/" ));
764+ Preconditions .checkArgument (rootUrl .endsWith ("/" ));
782765 this .rootUrl = rootUrl ;
783766 return this ;
784767 }
@@ -790,8 +773,8 @@ public Builder setRootUrl(GenericUrl rootUrl) {
790773 * {@code ""}.
791774 *
792775 * <p>
793- * Use this method only if {@link #builder(HttpTransport, JsonFactory, GenericUrl, String)} was
794- * used .
776+ * Use this method only if {@code rootUrl} and {@code servicePath} are used instead of
777+ * {@code baseUrl} .
795778 * </p>
796779 *
797780 * @since 1.10
@@ -808,8 +791,8 @@ public final String getServicePath() {
808791 * changed. Subclasses should override by calling super.
809792 *
810793 * <p>
811- * Use this method only if {@link #builder(HttpTransport, JsonFactory, GenericUrl, String)} was
812- * used .
794+ * Use this method only if {@code rootUrl} and {@code servicePath} are used instead of
795+ * {@code baseUrl} .
813796 * </p>
814797 *
815798 * @since 1.10
0 commit comments