1- /*
2- * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3- *
4- * Licensed under the Apache License, Version 2.0 (the "License").
5- * You may not use this file except in compliance with the License.
6- * A copy of the License is located at
7- *
8- * http://aws.amazon.com/apache2.0
9- *
10- * or in the "license" file accompanying this file. This file is distributed
11- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12- * express or implied. See the License for the specific language governing
13- * permissions and limitations under the License.
14- */
15-
161package software .amazon .awssdk .services .query .endpoints .internal ;
172
183import java .net .URI ;
@@ -31,7 +16,7 @@ public final class DefaultQueryEndpointProvider implements QueryEndpointProvider
3116 @ Override
3217 public CompletableFuture <Endpoint > resolveEndpoint (QueryEndpointParams params ) {
3318 try {
34- RuleResult result = endpointRule0 (params , new LocalState () );
19+ RuleResult result = endpointRule0 (params );
3520 if (result .canContinue ()) {
3621 throw SdkClientException .create ("Rule engine did not reach an error or endpoint result" );
3722 }
@@ -48,29 +33,21 @@ public CompletableFuture<Endpoint> resolveEndpoint(QueryEndpointParams params) {
4833 }
4934 }
5035
51- private static RuleResult endpointRule0 (QueryEndpointParams params , LocalState locals ) {
52- RuleResult result = endpointRule1 (params , locals );
36+ private static RuleResult endpointRule0 (QueryEndpointParams params ) {
37+ RuleResult result = endpointRule1 (params );
5338 if (result .isResolved ()) {
5439 return result ;
5540 }
56- return endpointRule3 ( params , locals );
41+ return RuleResult . error ( "Invalid Configuration: Missing Endpoint" );
5742 }
5843
59- private static RuleResult endpointRule1 (QueryEndpointParams params , LocalState locals ) {
44+ private static RuleResult endpointRule1 (QueryEndpointParams params ) {
6045 if (params .endpoint () != null ) {
61- return endpointRule2 ( params , locals );
46+ return RuleResult . endpoint ( Endpoint . builder (). url ( URI . create ( params . endpoint ())). build () );
6247 }
6348 return RuleResult .carryOn ();
6449 }
6550
66- private static RuleResult endpointRule2 (QueryEndpointParams params , LocalState locals ) {
67- return RuleResult .endpoint (Endpoint .builder ().url (URI .create (params .endpoint ())).build ());
68- }
69-
70- private static RuleResult endpointRule3 (QueryEndpointParams params , LocalState locals ) {
71- return RuleResult .error ("Invalid Configuration: Missing Endpoint" );
72- }
73-
7451 @ Override
7552 public boolean equals (Object rhs ) {
7653 return rhs != null && getClass ().equals (rhs .getClass ());
@@ -80,28 +57,4 @@ public boolean equals(Object rhs) {
8057 public int hashCode () {
8158 return getClass ().hashCode ();
8259 }
83-
84- private static final class LocalState {
85- LocalState () {
86- }
87-
88- LocalState (LocalStateBuilder builder ) {
89- }
90-
91- public LocalStateBuilder toBuilder () {
92- return new LocalStateBuilder (this );
93- }
94- }
95-
96- private static final class LocalStateBuilder {
97- LocalStateBuilder () {
98- }
99-
100- LocalStateBuilder (LocalState locals ) {
101- }
102-
103- LocalState build () {
104- return new LocalState (this );
105- }
106- }
10760}
0 commit comments