(Object obj)
| 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); |