• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2017 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 software.amazon.eventstream;
16 
17 enum HeaderType {
18     TRUE(0),
19     FALSE(1),
20     BYTE(2),
21     SHORT(3),
22     INTEGER(4),
23     LONG(5),
24     BYTE_ARRAY(6),
25     STRING(7),
26     TIMESTAMP(8),
27     UUID(9);
28 
29     final byte headerTypeId;
30 
HeaderType(int headerTypeId)31     HeaderType(int headerTypeId) {
32         this.headerTypeId = (byte) headerTypeId;
33     }
34 
fromTypeId(byte headerTypeId)35     static HeaderType fromTypeId(byte headerTypeId) {
36         switch (headerTypeId) {
37             case 0: return TRUE;
38             case 1: return FALSE;
39             case 2: return BYTE;
40             case 3: return SHORT;
41             case 4: return INTEGER;
42             case 5: return LONG;
43             case 6: return BYTE_ARRAY;
44             case 7: return STRING;
45             case 8: return TIMESTAMP;
46             case 9: return UUID;
47             default:
48                 throw new IllegalArgumentException("Got unknown headerTypeId " + headerTypeId);
49         }
50     }
51 }
52