mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Guava migration - Inline Predicates.compose
This commit is contained in:
@@ -8,7 +8,6 @@ import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import forge.util.Iterables;
|
||||
import forge.util.Predicates;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import forge.StaticData;
|
||||
@@ -206,7 +205,8 @@ public class DeckHints {
|
||||
private Iterable<PaperCard> getMatchingItems(Iterable<PaperCard> source, Predicate<CardRules> predicate, Function<PaperCard, CardRules> fn) {
|
||||
// TODO should token generators be counted differently for their potential?
|
||||
// And would there ever be a circumstance where `fn` should be anything but PaperCard::getRules?
|
||||
return Iterables.filter(source, Predicates.compose(tokens ? rulesWithTokens(predicate) : predicate, fn));
|
||||
Predicate<CardRules> predicate1 = tokens ? rulesWithTokens(predicate) : predicate;
|
||||
return Iterables.filter(source, x -> predicate1.test(fn.apply(x)));
|
||||
}
|
||||
|
||||
public static Predicate<CardRules> rulesWithTokens(final Predicate<CardRules> predicate) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.util;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class Predicates {
|
||||
@@ -15,9 +14,4 @@ public class Predicates {
|
||||
//TODO: Should be able to clean up the casting here.
|
||||
return x -> Iterables.any(components, (Predicate<Predicate<? super T>>) i -> i.test(x));
|
||||
}
|
||||
|
||||
//TODO: Most uses of this are with the function PaperCard::getRules. Maybe we should just have PaperCardPredicates?
|
||||
public static <A, B> Predicate<A> compose(Predicate<B> predicate, Function<A, ? extends B> function) {
|
||||
return x -> predicate.test(function.apply(x));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user