From a070feefb2e37af055d0e3bb1f9a3d1f61ba6c12 Mon Sep 17 00:00:00 2001 From: Jetz Date: Mon, 2 Sep 2024 18:19:04 -0400 Subject: [PATCH] Guava migration - Remove forwarding overloads --- .../src/main/java/forge/util/Iterables.java | 33 +----------- .../src/main/java/forge/util/Predicates.java | 54 +++---------------- 2 files changed, 7 insertions(+), 80 deletions(-) diff --git a/forge-core/src/main/java/forge/util/Iterables.java b/forge-core/src/main/java/forge/util/Iterables.java index c00a71ea200..8bc95859e66 100644 --- a/forge-core/src/main/java/forge/util/Iterables.java +++ b/forge-core/src/main/java/forge/util/Iterables.java @@ -57,6 +57,7 @@ public class Iterables { public static Iterable transform(final Iterable iterable, final Function function) { //TODO: Collection input variant. Some usages use Lists.newArrayList on output which could be made part of the stream. + //Should probably also be ? extends T in the function type return () -> StreamSupport.stream(iterable.spliterator(), false).map(function).iterator(); } @@ -173,36 +174,4 @@ public class Iterables { public static boolean isEmpty(Iterable iterable) { return com.google.common.collect.Iterables.isEmpty(iterable); } - - - //TODO: Delete everything below. - public static Iterable filter(Iterable iterable, com.google.common.base.Predicate filter) { - return com.google.common.collect.Iterables.filter(iterable, filter); - } - public static boolean any(Iterable iterable, com.google.common.base.Predicate filter) { - return com.google.common.collect.Iterables.any(iterable, filter); - } - public static boolean all(Iterable iterable, com.google.common.base.Predicate filter) { - return com.google.common.collect.Iterables.any(iterable, filter); - } - public static boolean removeIf(Iterable iterable, com.google.common.base.Predicate test) { - return com.google.common.collect.Iterables.removeIf(iterable, test); - } - public static T find(Iterable iterable, com.google.common.base.Predicate predicate) { - return com.google.common.collect.Iterables.find(iterable, predicate); - } - public static T find(Iterable iterable, com.google.common.base.Predicate predicate, T defaultValue) { - return com.google.common.collect.Iterables.find(iterable, predicate, defaultValue); - } - public static com.google.common.base.Optional tryFind(Iterable iterable, com.google.common.base.Predicate predicate) { - return com.google.common.collect.Iterables.tryFind(iterable, predicate); - } - - public static int indexOf(Iterable iterable, com.google.common.base.Predicate predicate) { - return com.google.common.collect.Iterables.indexOf(iterable, predicate); - } - - public static Iterable transform(Iterable iterable, com.google.common.base.Function function) { - return com.google.common.collect.Iterables.transform(iterable, function); - } } diff --git a/forge-core/src/main/java/forge/util/Predicates.java b/forge-core/src/main/java/forge/util/Predicates.java index b44d50088b1..c69729fa1cf 100644 --- a/forge-core/src/main/java/forge/util/Predicates.java +++ b/forge-core/src/main/java/forge/util/Predicates.java @@ -60,56 +60,14 @@ public class Predicates { //TODO: Uncomment all when switching off Guava. Then Inline. //TODO: This one probably needs case by case; nullable targets need a safe test, whereas nonnull targets can be simplified further. -// public static Predicate equalTo(T target) { -// return x -> Objects.equals(target, x); -// } - -// public static Predicate instanceOf(Class clazz) { -// return clazz::isInstance; -// } -// public static Predicate in(Collection target) { -// return target::contains; -// } - - - - //TODO: Delete everything below. - public static com.google.common.base.Predicate not(com.google.common.base.Predicate predicate) { - return com.google.common.base.Predicates.not(predicate); + public static Predicate equalTo(T target) { + return x -> Objects.equals(target, x); } - public static com.google.common.base.Predicate and(Iterable> components) { - return com.google.common.base.Predicates.and(components); + public static Predicate instanceOf(Class clazz) { + return clazz::isInstance; } - public static com.google.common.base.Predicate and(com.google.common.base.Predicate... components) { - return com.google.common.base.Predicates.and(components); - } - public static com.google.common.base.Predicate and(com.google.common.base.Predicate first, com.google.common.base.Predicate second) { - return com.google.common.base.Predicates.and(first, second); - } - public static com.google.common.base.Predicate or(Iterable> components) { - return com.google.common.base.Predicates.or(components); - } - public static com.google.common.base.Predicate or(com.google.common.base.Predicate... components) { - return com.google.common.base.Predicates.or(components); - } - public static com.google.common.base.Predicate or(com.google.common.base.Predicate first, com.google.common.base.Predicate second) { - return com.google.common.base.Predicates.or(first, second); - } - - public static com.google.common.base.Predicate equalTo(T target) { - return com.google.common.base.Predicates.equalTo(target); - } - public static com.google.common.base.Predicate instanceOf(Class clazz) { - return com.google.common.base.Predicates.instanceOf(clazz); - } - public static com.google.common.base.Predicate in(Collection target) { - return com.google.common.base.Predicates.in(target); - } - - public static com.google.common.base.Predicate compose( - com.google.common.base.Predicate predicate, - com.google.common.base.Function function) { - return com.google.common.base.Predicates.compose(predicate, function); + public static Predicate in(Collection target) { + return target::contains; } }