MCPcopy Create free account
hub / github.com/PCGen/pcgen / initializeTypeMap

Method initializeTypeMap

code/src/java/pcgen/cdom/enumeration/Region.java:114–142  ·  view source on GitHub ↗

Thread safe construction of typeMap

()

Source from the content-addressed store, hash-verified

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

Callers 2

getConstantMethod · 0.95
valueOfMethod · 0.95

Calls 5

getModifiersMethod · 0.80
isStaticMethod · 0.65
getMethod · 0.65
putMethod · 0.65
getNameMethod · 0.65

Tested by

no test coverage detected