Migrate toward java.util.function

- Package-private changes only
- Maintains binary and source compatibility
This commit is contained in:
Gary Gregory 2024-07-11 09:31:45 -04:00
parent 68c0814f23
commit ee307055b7
8 changed files with 13 additions and 11 deletions

View File

@ -51,7 +51,7 @@ public abstract class AbstractQuantifierPredicate<T> extends AbstractPredicate<T
*/ */
@Override @Override
public Predicate<? super T>[] getPredicates() { public Predicate<? super T>[] getPredicates() {
return FunctorUtils.<T>copy(iPredicates); return FunctorUtils.copy(iPredicates);
} }
} }

View File

@ -84,8 +84,8 @@ public final class AllPredicate<T> extends AbstractQuantifierPredicate<T> {
if (predicates.length == 1) { if (predicates.length == 1) {
return coerce(predicates[0]); return coerce(predicates[0]);
} }
// <T> not needed in Eclipse but needed by the command line compiler
return new AllPredicate<>(FunctorUtils.copy(predicates)); return new AllPredicate<T>(FunctorUtils.copy(predicates));
} }
/** /**

View File

@ -82,7 +82,7 @@ public final class AnyPredicate<T> extends AbstractQuantifierPredicate<T> {
if (predicates.length == 1) { if (predicates.length == 1) {
return (Predicate<T>) predicates[0]; return (Predicate<T>) predicates[0];
} }
return new AnyPredicate<>(FunctorUtils.copy(predicates)); return new AnyPredicate<T>(FunctorUtils.copy(predicates));
} }
/** /**

View File

@ -87,7 +87,7 @@ final class FunctorUtils {
* @return the cloned consumers. * @return the cloned consumers.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
static <C extends Consumer<?>> C[] copy(final C... consumers) { static <T extends Consumer<?>> T[] copy(final T... consumers) {
if (consumers == null) { if (consumers == null) {
return null; return null;
} }
@ -103,11 +103,11 @@ final class FunctorUtils {
* @return the cloned predicates * @return the cloned predicates
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
static <T> Predicate<T>[] copy(final Predicate<? super T>... predicates) { static <T extends java.util.function.Predicate<?>> T[] copy(final T... predicates) {
if (predicates == null) { if (predicates == null) {
return null; return null;
} }
return (Predicate<T>[]) predicates.clone(); return predicates.clone();
} }
/** /**

View File

@ -72,7 +72,8 @@ public final class NonePredicate<T> extends AbstractQuantifierPredicate<T> {
if (predicates.length == 0) { if (predicates.length == 0) {
return TruePredicate.<T>truePredicate(); return TruePredicate.<T>truePredicate();
} }
return new NonePredicate<>(FunctorUtils.copy(predicates)); // <T> not needed in Eclipse but needed by the command line compiler
return new NonePredicate<T>(FunctorUtils.copy(predicates));
} }
/** /**

View File

@ -72,7 +72,8 @@ public final class OnePredicate<T> extends AbstractQuantifierPredicate<T> {
if (predicates.length == 1) { if (predicates.length == 1) {
return (Predicate<T>) predicates[0]; return (Predicate<T>) predicates[0];
} }
return new OnePredicate<>(FunctorUtils.copy(predicates)); // <T> not needed in Eclipse but needed by the command line compiler
return new OnePredicate<T>(FunctorUtils.copy(predicates));
} }
/** /**

View File

@ -177,7 +177,7 @@ public class SwitchClosure<E> implements Closure<E>, Serializable {
* @since 3.1 * @since 3.1
*/ */
public Predicate<? super E>[] getPredicates() { public Predicate<? super E>[] getPredicates() {
return FunctorUtils.<E>copy(iPredicates); return FunctorUtils.copy(iPredicates);
} }
} }

View File

@ -164,7 +164,7 @@ public class SwitchTransformer<I, O> implements Transformer<I, O>, Serializable
* @since 3.1 * @since 3.1
*/ */
public Predicate<? super I>[] getPredicates() { public Predicate<? super I>[] getPredicates() {
return FunctorUtils.<I>copy(iPredicates); return FunctorUtils.copy(iPredicates);
} }
/** /**