| 349 | } |
| 350 | |
| 351 | public static <OT> ObjectKey<OT> getKeyFor(Class<OT> objectClass, String name) |
| 352 | { |
| 353 | if (map == null) |
| 354 | { |
| 355 | buildMap(); |
| 356 | } |
| 357 | /* |
| 358 | * CONSIDER This is actually not type safe, there is a case of asking |
| 359 | * for a String a second time with a different Class that ObjectKey |
| 360 | * currently does not handle. Two solutions: One, store this in a |
| 361 | * Two-Key map and allow a String to map to more than one ObjectKey |
| 362 | * given different output types (considered confusing) or Two, store the |
| 363 | * Class and validate that with a an error message if a different class |
| 364 | * is requested. |
| 365 | */ |
| 366 | ObjectKey<OT> key = (ObjectKey<OT>) map.get(name); |
| 367 | if (key == null) |
| 368 | { |
| 369 | key = new ObjectKey<>(null); |
| 370 | map.put(name, key); |
| 371 | } |
| 372 | return key; |
| 373 | } |
| 374 | |
| 375 | private static void buildMap() |
| 376 | { |