Guava migration - Remove forwarding overloads

This commit is contained in:
Jetz
2024-09-02 18:19:04 -04:00
parent 67f22c647d
commit a070feefb2
2 changed files with 7 additions and 80 deletions

View File

@@ -57,6 +57,7 @@ public class Iterables {
public static <F, T> Iterable<T> transform(final Iterable<F> iterable, final Function<? super F, T> function) { public static <F, T> Iterable<T> transform(final Iterable<F> iterable, final Function<? super F, T> function) {
//TODO: Collection input variant. Some usages use Lists.newArrayList on output which could be made part of the stream. //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(); return () -> StreamSupport.stream(iterable.spliterator(), false).map(function).iterator();
} }
@@ -173,36 +174,4 @@ public class Iterables {
public static boolean isEmpty(Iterable<?> iterable) { public static boolean isEmpty(Iterable<?> iterable) {
return com.google.common.collect.Iterables.isEmpty(iterable); return com.google.common.collect.Iterables.isEmpty(iterable);
} }
//TODO: Delete everything below.
public static <T> Iterable<T> filter(Iterable<T> iterable, com.google.common.base.Predicate<? super T> filter) {
return com.google.common.collect.Iterables.filter(iterable, filter);
}
public static <T> boolean any(Iterable<T> iterable, com.google.common.base.Predicate<? super T> filter) {
return com.google.common.collect.Iterables.any(iterable, filter);
}
public static <T> boolean all(Iterable<T> iterable, com.google.common.base.Predicate<? super T> filter) {
return com.google.common.collect.Iterables.any(iterable, filter);
}
public static <T> boolean removeIf(Iterable<T> iterable, com.google.common.base.Predicate<? super T> test) {
return com.google.common.collect.Iterables.removeIf(iterable, test);
}
public static <T> T find(Iterable<T> iterable, com.google.common.base.Predicate<? super T> predicate) {
return com.google.common.collect.Iterables.find(iterable, predicate);
}
public static <T> T find(Iterable<T> iterable, com.google.common.base.Predicate<? super T> predicate, T defaultValue) {
return com.google.common.collect.Iterables.find(iterable, predicate, defaultValue);
}
public static <T> com.google.common.base.Optional<T> tryFind(Iterable<T> iterable, com.google.common.base.Predicate<? super T> predicate) {
return com.google.common.collect.Iterables.tryFind(iterable, predicate);
}
public static <T> int indexOf(Iterable<T> iterable, com.google.common.base.Predicate<? super T> predicate) {
return com.google.common.collect.Iterables.indexOf(iterable, predicate);
}
public static <F, T> Iterable<T> transform(Iterable<F> iterable, com.google.common.base.Function<? super F, ? extends T> function) {
return com.google.common.collect.Iterables.transform(iterable, function);
}
} }

View File

@@ -60,56 +60,14 @@ public class Predicates {
//TODO: Uncomment all when switching off Guava. Then Inline. //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. //TODO: This one probably needs case by case; nullable targets need a safe test, whereas nonnull targets can be simplified further.
// public static <T> Predicate<T> equalTo(T target) { public static <T> Predicate<T> equalTo(T target) {
// return x -> Objects.equals(target, x); return x -> Objects.equals(target, x);
// }
// public static <T> Predicate<T> instanceOf(Class<?> clazz) {
// return clazz::isInstance;
// }
// public static <T> Predicate<T> in(Collection<? extends T> target) {
// return target::contains;
// }
//TODO: Delete everything below.
public static <T> com.google.common.base.Predicate<T> not(com.google.common.base.Predicate<T> predicate) {
return com.google.common.base.Predicates.not(predicate);
} }
public static <T> com.google.common.base.Predicate<T> and(Iterable<? extends com.google.common.base.Predicate<? super T>> components) { public static <T> Predicate<T> instanceOf(Class<?> clazz) {
return com.google.common.base.Predicates.and(components); return clazz::isInstance;
} }
public static <T> com.google.common.base.Predicate<T> and(com.google.common.base.Predicate<? super T>... components) { public static <T> Predicate<T> in(Collection<? extends T> target) {
return com.google.common.base.Predicates.and(components); return target::contains;
}
public static <T> com.google.common.base.Predicate<T> and(com.google.common.base.Predicate<? super T> first, com.google.common.base.Predicate<? super T> second) {
return com.google.common.base.Predicates.and(first, second);
}
public static <T> com.google.common.base.Predicate<T> or(Iterable<? extends com.google.common.base.Predicate<? super T>> components) {
return com.google.common.base.Predicates.or(components);
}
public static <T> com.google.common.base.Predicate<T> or(com.google.common.base.Predicate<? super T>... components) {
return com.google.common.base.Predicates.or(components);
}
public static <T> com.google.common.base.Predicate<T> or(com.google.common.base.Predicate<? super T> first, com.google.common.base.Predicate<? super T> second) {
return com.google.common.base.Predicates.or(first, second);
}
public static <T> com.google.common.base.Predicate<T> equalTo(T target) {
return com.google.common.base.Predicates.equalTo(target);
}
public static <T> com.google.common.base.Predicate<T> instanceOf(Class<?> clazz) {
return com.google.common.base.Predicates.instanceOf(clazz);
}
public static <T> com.google.common.base.Predicate<T> in(Collection<? extends T> target) {
return com.google.common.base.Predicates.in(target);
}
public static <A, B> com.google.common.base.Predicate<A> compose(
com.google.common.base.Predicate<B> predicate,
com.google.common.base.Function<A, ? extends B> function) {
return com.google.common.base.Predicates.compose(predicate, function);
} }
} }