1 /*
2  * Copyright 2015-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5  * the License. A copy of the License is located at
6  * 
7  * http://aws.amazon.com/apache2.0
8  * 
9  * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10  * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11  * and limitations under the License.
12  */

13
14 package software.amazon.awssdk.regions;
15
16 import java.util.Map;
17 import software.amazon.awssdk.annotations.Generated;
18 import software.amazon.awssdk.annotations.SdkPublicApi;
19 import software.amazon.awssdk.regions.partitionmetadata.AwsCnPartitionMetadata;
20 import software.amazon.awssdk.regions.partitionmetadata.AwsIsoBPartitionMetadata;
21 import software.amazon.awssdk.regions.partitionmetadata.AwsIsoPartitionMetadata;
22 import software.amazon.awssdk.regions.partitionmetadata.AwsPartitionMetadata;
23 import software.amazon.awssdk.regions.partitionmetadata.AwsUsGovPartitionMetadata;
24 import software.amazon.awssdk.utils.ImmutableMap;
25
26 @Generated("software.amazon.awssdk:codegen")
27 @SdkPublicApi
28 public final class GeneratedPartitionMetadataProvider implements PartitionMetadataProvider {
29     private static final Map<String, PartitionMetadata> PARTITION_METADATA = ImmutableMap.<String, PartitionMetadata> builder()
30             .put("aws"new AwsPartitionMetadata()).put("aws-cn"new AwsCnPartitionMetadata())
31             .put("aws-us-gov"new AwsUsGovPartitionMetadata()).put("aws-iso"new AwsIsoPartitionMetadata())
32             .put("aws-iso-b"new AwsIsoBPartitionMetadata()).build();
33
34     public PartitionMetadata partitionMetadata(String partition) {
35         return PARTITION_METADATA.get(partition);
36     }
37
38     public PartitionMetadata partitionMetadata(Region region) {
39         return PARTITION_METADATA.values().stream().filter(p -> region.id().matches(p.regionRegex())).findFirst()
40                 .orElse(new AwsPartitionMetadata());
41     }
42 }
43