MCPcopy Create free account
hub / github.com/egg82/fetcharr / build

Method build

Lib/src/main/java/me/egg82/arr/parse/ObjectParser.java:51–75  ·  view source on GitHub ↗
(@NotNull Class<T> type, @NotNull ArrAPI api, @NotNull JSONObject val, boolean silent)

Source from the content-addressed store, hash-verified

49 }
50
51 private static <T extends APIObject> @Nullable T build(@NotNull Class<T> type, @NotNull ArrAPI api, @NotNull JSONObject val, boolean silent) {
52 Constructor<?> c = constructors.computeIfAbsent(type, k -> {
53 try {
54 return type.getConstructor(ArrAPI.class, JSONObject.class);
55 } catch (NoSuchMethodException ex) {
56 if (!silent) {
57 LOGGER.error("Could not find API constructor for class {}", type.getName(), ex);
58 }
59 }
60 return null;
61 });
62
63 if (c == null) {
64 return null;
65 }
66
67 try {
68 return type.cast(c.newInstance(api, val));
69 } catch (InvocationTargetException | InstantiationException | IllegalAccessException | IllegalArgumentException ex) {
70 if (!silent) {
71 LOGGER.error("Could not create new instance of class {}", type.getName(), ex);
72 }
73 }
74 return null;
75 }
76
77 private ObjectParser() { }
78}

Callers 5

getMethod · 0.95
loadConfigMethod · 0.45
readDescriptorMethod · 0.45
downloadPluginsMethod · 0.45
readManifestMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected