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

Method buildMap

code/src/java/pcgen/cdom/enumeration/EqModNameOpt.java:184–215  ·  view source on GitHub ↗

Actually build the set of Constants, using any "public static final" constants within the child (extending) class as initial values in the Constant pool.

()

Source from the content-addressed store, hash-verified

182 * Constant pool.
183 */
184 private static void buildMap()
185 {
186 typeMap = new CaseInsensitiveMap<>();
187 Class<EqModNameOpt> thisClass = EqModNameOpt.class;
188 for (Field f : thisClass.getDeclaredFields())
189 {
190 int mod = f.getModifiers();
191 String name = f.getName();
192
193 if (Modifier.isStatic(mod) && Modifier.isFinal(mod) && Modifier.isPublic(mod))
194 {
195 try
196 {
197 Object obj = f.get(null);
198 if (thisClass.isAssignableFrom(obj.getClass()))
199 {
200 EqModNameOpt tObj = thisClass.cast(obj);
201 if (typeMap.containsKey(name))
202 {
203 throw new UnreachableError(
204 "Attempt to redefine constant value " + name + ", value was " + typeMap.get(name));
205 }
206 typeMap.put(name, tObj);
207 }
208 }
209 catch (IllegalArgumentException | IllegalAccessException e)
210 {
211 throw new UnreachableError(e);
212 }
213 }
214 }
215 }
216
217 public String associatedList(List<String> associatedList)
218 {

Callers 1

valueOfIgnoreCaseMethod · 0.95

Calls 7

getModifiersMethod · 0.80
getNameMethod · 0.65
isStaticMethod · 0.65
getMethod · 0.65
containsKeyMethod · 0.65
putMethod · 0.65
castMethod · 0.45

Tested by

no test coverage detected