private static void incorporateCounter(SetField thunk, JhCounters counters, String counterName) { counterName = canonicalizeCounterName(counterName); for (JhCounterGroup group : counters.groups) { for (JhCounter counter : group.counts) { if (counterName .equals(canonicalizeCounterName(counter.name.toString()))) { thunk.set(counter.value); return; } } } }
/** * Extract/Add counters into the Map from the given JhCounters object. * @param counters the counters to be extracted from * @return the map of counters */ static Map<String, Long> extractCounters(JhCounters counters) { Map<String, Long> countersMap = new HashMap<String, Long>(); if (counters != null) { for (JhCounterGroup group : counters.groups) { for (JhCounter counter : group.counts) { countersMap.put(counter.name.toString(), counter.value); } } } return countersMap; }