• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 package software.amazon.awssdk.crt.http;
7 
8 import java.util.Map;
9 import java.util.HashMap;
10 
11 public enum HttpVersion {
12 
13     UNKNOWN(0),
14     HTTP_1_0(1),
15     HTTP_1_1(2),
16     HTTP_2(3);
17 
18     private int value;
19     private static Map<Integer, HttpVersion> enumMapping = buildEnumMapping();
20 
HttpVersion(int value)21     HttpVersion(int value) {
22         this.value = value;
23     }
24 
getEnumValueFromInteger(int value)25     public static HttpVersion getEnumValueFromInteger(int value) {
26         HttpVersion enumValue = enumMapping.get(value);
27         if (enumValue != null) {
28             return enumValue;
29         }
30 
31         throw new RuntimeException("Illegal signature type value in signing configuration");
32     }
33 
buildEnumMapping()34     private static Map<Integer, HttpVersion> buildEnumMapping() {
35         Map<Integer, HttpVersion> enumMapping = new HashMap<Integer, HttpVersion>();
36         enumMapping.put(UNKNOWN.getValue(), UNKNOWN);
37         enumMapping.put(HTTP_1_0.getValue(), HTTP_1_0);
38         enumMapping.put(HTTP_1_1.getValue(), HTTP_1_1);
39         enumMapping.put(HTTP_2.getValue(), HTTP_2);
40 
41         return enumMapping;
42     }
43 
getValue()44     public int getValue() {
45         return value;
46     }
47 }
48