Thread safe construction of typeMap
()
| 112 | * Thread safe construction of typeMap |
| 113 | */ |
| 114 | private static synchronized void initializeTypeMap() |
| 115 | { |
| 116 | if (typeMap == null) |
| 117 | { |
| 118 | typeMap = new CaseInsensitiveMap<>(); |
| 119 | Field[] fields = Region.class.getDeclaredFields(); |
| 120 | for (Field field : fields) |
| 121 | { |
| 122 | int mod = field.getModifiers(); |
| 123 | |
| 124 | if (java.lang.reflect.Modifier.isStatic(mod) |
| 125 | && java.lang.reflect.Modifier.isFinal(mod) |
| 126 | && java.lang.reflect.Modifier.isPublic(mod)) |
| 127 | { |
| 128 | try |
| 129 | { |
| 130 | Object obj = field.get(null); |
| 131 | if (obj instanceof Region) |
| 132 | { |
| 133 | typeMap.put(field.getName(), (Region) obj); |
| 134 | } |
| 135 | } catch (IllegalArgumentException | IllegalAccessException e) |
| 136 | { |
| 137 | throw new UnreachableError(e); |
| 138 | } |
| 139 | } |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * Returns the constant for the given String (the search for the constant is |
no test coverage detected