* @return the number of occurrences
* @since 1.8.0
*/
public static <K,V> Number count(Map<K,V> self, @ClosureParams(MapEntryOrKeyValue.class) Closure<?> closure) {
long answer = 0;
BooleanClosureWrapper bcw = new BooleanClosureWrapper(closure);
for (Object entry : self.entrySet()) {
if (bcw.callForMap((Map.Entry)entry)) {
++answer;
}
}
// for b/c with Java return an int if we can
if (answer <= Integer.MAX_VALUE) return (int) answer;