MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / create

Method create

patterns/trash/DynaFactory.java:18–31  ·  view source on GitHub ↗
(TrashInfo info)

Source from the content-addressed store, hash-verified

16 this.packageName = packageName;
17 }
18 @SuppressWarnings("unchecked")
19 public
20 <T extends Trash> T create(TrashInfo info) {
21 try {
22 String typename =
23 "patterns." + packageName + "." + info.type;
24 return (T)constructors.computeIfAbsent(
25 typename, this::findConstructor
26 ).newInstance(info.data);
27 } catch(Exception e) {
28 throw new RuntimeException(
29 "Cannot create() Trash: " + info, e);
30 }
31 }
32 private
33 Constructor findConstructor(String typename) {
34 try {

Callers 1

fillBinMethod · 0.95

Calls 1

newInstanceMethod · 0.80

Tested by

no test coverage detected