Actually build the set of Constants, using any "public static final" constants within the child (extending) class as initial values in the Constant pool.
()
| 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 | { |
no test coverage detected