diff --git a/forge-core/src/main/java/forge/util/ItemPool.java b/forge-core/src/main/java/forge/util/ItemPool.java
index 7a065ca1639..8222f61f597 100644
--- a/forge-core/src/main/java/forge/util/ItemPool.java
+++ b/forge-core/src/main/java/forge/util/ItemPool.java
@@ -31,7 +31,9 @@ import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
+import com.google.common.collect.Maps;
import forge.item.InventoryItem;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
*
@@ -137,30 +139,26 @@ public class ItemPool implements Iterable int countAll(Predicate condition){
+ public int countAll(Predicate condition){
int count = 0;
- Iterable matchingKeys = Iterables.filter(this.items.keySet(), new Predicate() {
- @Override
- public boolean apply(T item) {
- return condition.apply((U)item);
- }
- });
- for (T key : matchingKeys)
- count += this.items.get(key);
+ for (Integer v : Maps.filterKeys(this.items, condition).values())
+ count += v;
return count;
+
}
@SuppressWarnings("unchecked")
public final int countAll(Predicate condition, Class cls) {
int count = 0;
- Iterable matchingKeys = Iterables.filter(this.items.keySet(), new Predicate() {
+ Map matchingKeys = Maps.filterKeys(this.items, new Predicate() {
@Override
public boolean apply(T item) {
- return cls.isInstance(item) && condition.apply((U)item);
+ return cls.isInstance(item) && (condition.apply((U)item));
}
});
- for (T key : matchingKeys)
- count += this.items.get(key);
+ for (Integer i : matchingKeys.values()) {
+ count += i;
+ }
return count;
}