1 /*
2 * Copyright 2010-2020 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 package com.amazonaws.http;
16
17 import com.amazonaws.util.StringUtils;
18
19 public enum HttpMethodName {
20
21 GET,
22 POST,
23 PUT,
24 DELETE,
25 HEAD,
26 PATCH,
27 OPTIONS,
28 ;
29
30 /**
31 * @param value Raw string representing value of enum
32 * @return HttpMethodName enum or null if value is not present.
33 * @throws IllegalArgumentException If value does not represent a known enum value.
34 */
35 public static HttpMethodName fromValue(String value) {
36 if (StringUtils.isNullOrEmpty(value)) {
37 return null;
38 }
39
40 final String upperCaseValue = StringUtils.upperCase(value);
41 for (HttpMethodName httpMethodName : values()) {
42 if (httpMethodName.name().equals(upperCaseValue)) {
43 return httpMethodName;
44 }
45 }
46 throw new IllegalArgumentException("Unsupported HTTP method name " + value);
47 }
48
49 }
50