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 
16 package software.amazon.awssdk.services.s3.internal.resource;
17 
18 
19 import software.amazon.awssdk.annotations.SdkInternalApi;
20 import software.amazon.awssdk.utils.StringUtils;
21 
22 /**
23  * An enum representing the types of resources supported by S3 outpost. Each resource type below will have a
24  * concrete implementation of {@link S3OutpostResource}.
25  */
26 @SdkInternalApi
27 public enum OutpostResourceType {
28 
29     /**
30      * A specific S3 outpost bucket.
31      */
32     OUTPOST_BUCKET("bucket"),
33 
34     /**
35      * An outpost access point
36      */
37     OUTPOST_ACCESS_POINT("accesspoint");
38 
39     private final String value;
40 
OutpostResourceType(String value)41     OutpostResourceType(String value) {
42         this.value = value;
43     }
44 
45     /**
46      * @return The canonical string value of this resource type.
47      */
48     @Override
toString()49     public String toString() {
50         return value;
51     }
52 
53     /**
54      * Use this in place of valueOf.
55      *
56      * @param value real value
57      * @return S3ResourceType corresponding to the value
58      * @throws IllegalArgumentException If the specified value does not map to one of the known values in this enum.
59      */
fromValue(String value)60     public static OutpostResourceType fromValue(String value) {
61         if (StringUtils.isEmpty(value)) {
62             throw new IllegalArgumentException("value cannot be null or empty!");
63         }
64 
65         for (OutpostResourceType enumEntry : OutpostResourceType.values()) {
66             if (enumEntry.toString().equals(value)) {
67                 return enumEntry;
68             }
69         }
70 
71         throw new IllegalArgumentException("Cannot create enum from " + value + " value!");
72     }
73 }
74