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

Method count

onjava/TypeCounter.java:16–23  ·  view source on GitHub ↗
(Object obj)

Source from the content-addressed store, hash-verified

14 this.baseType = baseType;
15 }
16 public void count(Object obj) {
17 Class<?> type = obj.getClass();
18 if(!baseType.isAssignableFrom(type))
19 throw new RuntimeException(
20 obj + " incorrect type: " + type +
21 ", should be type or subtype of " + baseType);
22 countClass(type);
23 }
24 private void countClass(Class<?> type) {
25 Integer quantity = get(type);
26 put(type, quantity == null ? 1 : quantity + 1);

Callers 7

watchDirMethod · 0.45
mainMethod · 0.45
mainMethod · 0.45
mainMethod · 0.45
testMethod · 0.45
testMethod · 0.45
commandMethod · 0.45

Calls 1

countClassMethod · 0.95

Tested by 1

testMethod · 0.36