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

Method getFacet

code/src/java/pcgen/cdom/facet/FacetLibrary.java:41–65  ·  view source on GitHub ↗
(Class<T> cl)

Source from the content-addressed store, hash-verified

39 private static final Map<Class<?>, Object> facets = new HashMap<>();
40
41 public static <T> T getFacet(Class<T> cl)
42 {
43 T facet = (T) facets.get(cl);
44 if (facet == null)
45 {
46 // First check for the facet being defined by Spring
47 facet = SpringHelper.getBean(cl);
48 if (facet == null)
49 {
50 // Fall back to the old hardcoded system
51 Logging.errorPrint("Using Legacy Load for Facet: " + cl.getName(),
52 (Object) Thread.currentThread().getStackTrace());
53 try
54 {
55 facet = cl.getConstructor().newInstance();
56 }
57 catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e)
58 {
59 Logging.errorPrint("unable to construct old style Facet", e);
60 }
61 }
62 facets.put(cl, facet);
63 }
64 return facet;
65 }
66
67}

Callers 15

SpellLevelTestClass · 0.95
InputFunctionTestClass · 0.95
setUpMethod · 0.95
staticSetUpMethod · 0.95
initializeMethod · 0.95
initializeMethod · 0.95
getFaceMethod · 0.95
getReachTokenMethod · 0.95
passesMethod · 0.95
passesMethod · 0.95
closeCharacterMethod · 0.95
initForCharacterMethod · 0.95

Calls 6

getBeanMethod · 0.95
errorPrintMethod · 0.95
getMethod · 0.65
getNameMethod · 0.65
newInstanceMethod · 0.65
putMethod · 0.65

Tested by 15

setUpMethod · 0.76
staticSetUpMethod · 0.76
passesMethod · 0.76
passesMethod · 0.76
targetFacetCountMethod · 0.76
setUpMethod · 0.76
testDirectMethod · 0.76
setUpMethod · 0.76
setUpMethod · 0.76
setUpMethod · 0.76
setUpMethod · 0.76
setUpMethod · 0.76