Guava migration - Inline Iterables.all (Collection overload)

This commit is contained in:
Jetz
2024-09-08 15:29:41 -04:00
parent 7e3bb81428
commit cf68a75c03
2 changed files with 2 additions and 6 deletions

View File

@@ -66,9 +66,6 @@ public class Iterables {
public static <T> Iterable<T> filter(Collection<T> iterable, Predicate<? super T> filter) {
return () -> iterable.stream().filter(filter).iterator();
}
public static <T> boolean all(Collection<T> iterable, Predicate<? super T> test) {
return iterable.stream().allMatch(test);
}
public static int size(Collection<?> collection) {

View File

@@ -4,7 +4,6 @@ import forge.game.Game;
import forge.game.player.Player;
import forge.game.player.PlayerCollection;
import forge.game.player.PlayerPredicates;
import forge.util.Iterables;
import forge.util.Localizer;
public class AgainstAllOdds extends Achievement {
@@ -25,9 +24,9 @@ public class AgainstAllOdds extends Achievement {
for (Player opp : player.getRegisteredOpponents()) {
PlayerCollection otherOpps = player.getRegisteredOpponents();
otherOpps.remove(opp);
if (Iterables.all(otherOpps, PlayerPredicates.sameTeam(opp))) {
if (otherOpps.stream().allMatch(PlayerPredicates.sameTeam(opp))) {
teamNum++;
} else if (Iterables.all(otherOpps, PlayerPredicates.sameTeam(opp).negate())) {
} else if (otherOpps.stream().allMatch(PlayerPredicates.sameTeam(opp).negate())) {
teamNum--;
}
}