Skip to content

Commit 3213e5d

Browse files
committed
chore: Keep the builder pattern for the constructor
1 parent 47a39a8 commit 3213e5d

1 file changed

Lines changed: 7 additions & 22 deletions

File tree

google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/StsRequestHandler.java

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -76,26 +76,12 @@ public final class StsRequestHandler {
7676
@Nullable private final HttpHeaders headers;
7777
@Nullable private final String internalOptions;
7878

79-
/**
80-
* Internal constructor.
81-
*
82-
* @param tokenExchangeEndpoint the token exchange endpoint
83-
* @param request the token exchange request
84-
* @param headers optional additional headers to pass along the request
85-
* @param internalOptions optional GCP specific STS options
86-
* @return an StsTokenExchangeResponse instance if the request was successful
87-
*/
88-
private StsRequestHandler(
89-
String tokenExchangeEndpoint,
90-
StsTokenExchangeRequest request,
91-
HttpRequestFactory httpRequestFactory,
92-
@Nullable HttpHeaders headers,
93-
@Nullable String internalOptions) {
94-
this.tokenExchangeEndpoint = tokenExchangeEndpoint;
95-
this.request = request;
96-
this.httpRequestFactory = httpRequestFactory;
97-
this.headers = headers;
98-
this.internalOptions = internalOptions;
79+
private StsRequestHandler(Builder builder) {
80+
this.tokenExchangeEndpoint = builder.tokenExchangeEndpoint;
81+
this.request = builder.request;
82+
this.httpRequestFactory = builder.httpRequestFactory;
83+
this.headers = builder.headers;
84+
this.internalOptions = builder.internalOptions;
9985
}
10086

10187
/**
@@ -248,8 +234,7 @@ public StsRequestHandler.Builder setInternalOptions(String internalOptions) {
248234
}
249235

250236
public StsRequestHandler build() {
251-
return new StsRequestHandler(
252-
tokenExchangeEndpoint, request, httpRequestFactory, headers, internalOptions);
237+
return new StsRequestHandler(this);
253238
}
254239
}
255240
}

0 commit comments

Comments
 (0)