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

Method Counter

reflection/PetCounter3.java:14–19  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12 static class Counter extends
13 HashMap<Class<? extends Pet>, Integer> {
14 Counter() {
15 super(PetCreator.ALL_TYPES.stream()
16 .map(type -> Pair.make(type, 0))
17 .collect(
18 Collectors.toMap(Pair::key, Pair::value)));
19 }
20 public void count(Pet pet) {
21 // Class.isInstance() eliminates instanceofs:
22 entrySet().stream()

Callers

nothing calls this directly

Calls 2

makeMethod · 0.95
streamMethod · 0.45

Tested by

no test coverage detected