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

Method fillBin

patterns/trash/ParseTrash.java:17–38  ·  view source on GitHub ↗
(String packageName, Fillable<T> bin)

Source from the content-addressed store, hash-verified

15public class ParseTrash {
16 public static String source = "Trash.dat";
17 public static <T extends Trash> void
18 fillBin(String packageName, Fillable<T> bin) {
19 DynaFactory factory =
20 new DynaFactory(packageName);
21 try {
22 Files.lines(Paths.get("trash", source))
23 // Remove comments and empty lines:
24 .filter(line -> line.trim().length() != 0)
25 .filter(line -> !line.startsWith("//"))
26 .forEach(line -> {
27 String type = line.substring(
28 0, line.indexOf(':')).trim();
29 double weight = Double.valueOf(
30 line.substring(line.indexOf(':') + 1)
31 .trim());
32 bin.addTrash(factory.create(
33 new TrashInfo(type, weight)));
34 });
35 } catch(IOException | NumberFormatException e) {
36 throw new RuntimeException(e);
37 }
38 }
39 // Special case to handle a List:
40 public static <T extends Trash> void
41 fillBin(String packageName, List<T> bin) {

Callers 7

mainMethod · 0.95
mainMethod · 0.95
mainMethod · 0.95
mainMethod · 0.95
mainMethod · 0.95
mainMethod · 0.95
mainMethod · 0.95

Calls 4

createMethod · 0.95
trimMethod · 0.80
getMethod · 0.65
addTrashMethod · 0.65

Tested by

no test coverage detected