1212import java .util .Optional ;
1313import okhttp3 .OkHttpClient ;
1414
15- public class AsyncBaseClientBuilder {
15+ public class AsyncBaseClientBuilder < T extends AsyncBaseClientBuilder < T >> {
1616 private Optional <Integer > timeout = Optional .empty ();
1717
1818 private Optional <Integer > maxRetries = Optional .empty ();
@@ -35,60 +35,68 @@ public class AsyncBaseClientBuilder {
3535 * Sets clientId.
3636 * Defaults to the PIPEDREAM_CLIENT_ID environment variable.
3737 */
38- public AsyncBaseClientBuilder clientId (String clientId ) {
38+ @ SuppressWarnings ("unchecked" )
39+ public T clientId (String clientId ) {
3940 this .clientId = clientId ;
40- return this ;
41+ return ( T ) this ;
4142 }
4243
4344 /**
4445 * Sets clientSecret.
4546 * Defaults to the PIPEDREAM_CLIENT_SECRET environment variable.
4647 */
47- public AsyncBaseClientBuilder clientSecret (String clientSecret ) {
48+ @ SuppressWarnings ("unchecked" )
49+ public T clientSecret (String clientSecret ) {
4850 this .clientSecret = clientSecret ;
49- return this ;
51+ return ( T ) this ;
5052 }
5153
5254 /**
5355 * Sets projectEnvironment
5456 */
55- public AsyncBaseClientBuilder projectEnvironment (String projectEnvironment ) {
57+ @ SuppressWarnings ("unchecked" )
58+ public T projectEnvironment (String projectEnvironment ) {
5659 this .projectEnvironment = projectEnvironment ;
57- return this ;
60+ return ( T ) this ;
5861 }
5962
60- public AsyncBaseClientBuilder environment (Environment environment ) {
63+ @ SuppressWarnings ("unchecked" )
64+ public T environment (Environment environment ) {
6165 this .environment = environment ;
62- return this ;
66+ return ( T ) this ;
6367 }
6468
65- public AsyncBaseClientBuilder url (String url ) {
69+ @ SuppressWarnings ("unchecked" )
70+ public T url (String url ) {
6671 this .environment = Environment .custom (url );
67- return this ;
72+ return ( T ) this ;
6873 }
6974
7075 /**
7176 * Sets the timeout (in seconds) for the client. Defaults to 60 seconds.
7277 */
73- public AsyncBaseClientBuilder timeout (int timeout ) {
78+ @ SuppressWarnings ("unchecked" )
79+ public T timeout (int timeout ) {
7480 this .timeout = Optional .of (timeout );
75- return this ;
81+ return ( T ) this ;
7682 }
7783
7884 /**
7985 * Sets the maximum number of retries for the client. Defaults to 2 retries.
8086 */
81- public AsyncBaseClientBuilder maxRetries (int maxRetries ) {
87+ @ SuppressWarnings ("unchecked" )
88+ public T maxRetries (int maxRetries ) {
8289 this .maxRetries = Optional .of (maxRetries );
83- return this ;
90+ return ( T ) this ;
8491 }
8592
8693 /**
8794 * Sets the underlying OkHttp client
8895 */
89- public AsyncBaseClientBuilder httpClient (OkHttpClient httpClient ) {
96+ @ SuppressWarnings ("unchecked" )
97+ public T httpClient (OkHttpClient httpClient ) {
9098 this .httpClient = httpClient ;
91- return this ;
99+ return ( T ) this ;
92100 }
93101
94102 /**
@@ -99,14 +107,16 @@ public AsyncBaseClientBuilder httpClient(OkHttpClient httpClient) {
99107 * @param value The header value
100108 * @return This builder for method chaining
101109 */
102- public AsyncBaseClientBuilder addHeader (String name , String value ) {
110+ @ SuppressWarnings ("unchecked" )
111+ public T addHeader (String name , String value ) {
103112 this .customHeaders .put (name , value );
104- return this ;
113+ return ( T ) this ;
105114 }
106115
107- public AsyncBaseClientBuilder projectId (String projectId ) {
116+ @ SuppressWarnings ("unchecked" )
117+ public T projectId (String projectId ) {
108118 this .projectId = projectId ;
109- return this ;
119+ return ( T ) this ;
110120 }
111121
112122 protected ClientOptions buildClientOptions () {
0 commit comments