File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package mil .nga .sf ;
22
3+ import java .util .HashMap ;
34import java .util .Locale ;
5+ import java .util .Map ;
46
57/**
68 * Geometry Type enumeration
@@ -113,6 +115,16 @@ public enum GeometryType {
113115 */
114116 TRIANGLE ;
115117
118+ /**
119+ * Name to type mapping for fast find attempts
120+ */
121+ private static final Map <String , GeometryType > types = new HashMap <>();
122+ static {
123+ for (GeometryType type : values ()) {
124+ types .put (type .name (), type );
125+ }
126+ }
127+
116128 /**
117129 * Get the name, just use the enum name since they are the same
118130 *
@@ -142,14 +154,7 @@ public static GeometryType fromName(String name) {
142154 * @since 2.0.2
143155 */
144156 public static GeometryType findName (String name ) {
145- GeometryType type = null ;
146- for (GeometryType geometryType : GeometryType .values ()) {
147- if (geometryType .name ().equalsIgnoreCase (name )) {
148- type = geometryType ;
149- break ;
150- }
151- }
152- return type ;
157+ return types .get (name .toUpperCase (Locale .US ));
153158 }
154159
155160}
You can’t perform that action at this time.
0 commit comments