1 /*
2 * Copyright (C) 2012 Alberto Irurueta Carro (alberto@irurueta.com)
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 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package com.irurueta.geometry.io;
17
18 import java.util.HashMap;
19 import java.util.Map;
20
21 /**
22 * Enumeration defining supported data types for PLY format.
23 */
24 public enum DataTypePLY {
25 /**
26 * Signed 8-bit integer.
27 */
28 PLY_INT8("int8"),
29
30 /**
31 * Unsigned 8-bit integer.
32 */
33 PLY_UINT8("uint8"),
34
35 /**
36 * Signed 16-bit integer.
37 */
38 PLY_INT16("int16"),
39
40 /**
41 * Unsigned 16-bit integer.
42 */
43 PLY_UINT16("uint16"),
44
45 /**
46 * Signed 32-bit integer.
47 */
48 PLY_INT32("int32"),
49
50 /**
51 * Unsigned 32-bit integer.
52 */
53 PLY_UINT32("uint32"),
54
55 /**
56 * 32-bit floating-point.
57 */
58 PLY_FLOAT32("float32"),
59
60 /**
61 * 64-bit floating-point.
62 */
63 PLY_FLOAT64("float64"),
64
65 /**
66 * Signed character (signed 8-bit integer).
67 */
68 PLY_CHAR("char"),
69
70 /**
71 * Unsigned character (unsigned 8-bit integer).
72 */
73 PLY_UCHAR("uchar"),
74
75 /**
76 * Signed short (signed 16-bit integer).
77 */
78 PLY_SHORT("short"),
79
80 /**
81 * Unsigned short (unsigned 16-bit integer).
82 */
83 PLY_USHORT("ushort"),
84
85 /**
86 * Signed integer (signed 32-bit integer).
87 */
88 PLY_INT("int"),
89
90 /**
91 * Unsigned integer (unsigned 32-bit integer).
92 */
93 PLY_UINT("uint"),
94
95 /**
96 * Float (32-bit floating-point).
97 */
98 PLY_FLOAT("float"),
99
100 /**
101 * Double (64-bit floating-point).
102 */
103 PLY_DOUBLE("double");
104
105 private static final Map<String, DataTypePLY> LOOKUP = new HashMap<>();
106
107 static {
108 for (final var value : DataTypePLY.values()) {
109 LOOKUP.put(value.getValue(), value);
110 }
111 }
112
113 /**
114 * Internal representation of this enum as a string.
115 */
116 private final String value;
117
118 /**
119 * Constructor of this enum with a string representation.
120 *
121 * @param value String value for this enum.
122 */
123 DataTypePLY(String value) {
124 this.value = value;
125 }
126
127 /**
128 * Returns string representation of an instance of this enum.
129 *
130 * @return String representation.
131 */
132 public String getValue() {
133 return this.value;
134 }
135
136 /**
137 * Builds an instance of this enum.
138 *
139 * @param value String representation of this enum.
140 * @return An instance of this enum.
141 */
142 public static DataTypePLY forValue(final String value) {
143 if (value != null) {
144 return LOOKUP.get(value);
145 }
146 return null;
147 }
148 }