/** * Create a new Predicate that returns true only if all of the specified * predicates are true. * If the array of predicates is empty, then this predicate returns true. * * @param <T> the type that the predicate queries * @param predicates an array of predicates to check, may not be null * @return the <code>all</code> predicate * @throws NullPointerException if the predicates array is null * @throws NullPointerException if any predicate in the array is null * @see AllPredicate */ public static <T> Predicate<T> allPredicate(final Predicate<? super T>... predicates) { return AllPredicate.allPredicate(predicates); }
/** * Factory to create the predicate. * <p> * If the collection is size zero, the predicate always returns true. * If the collection is size one, then that predicate is returned. * * @param <T> the type that the predicate queries * @param predicates the predicates to check, cloned, not null * @return the <code>all</code> predicate * @throws NullPointerException if the predicates array is null * @throws NullPointerException if any predicate in the array is null */ public static <T> Predicate<T> allPredicate(final Collection<? extends Predicate<? super T>> predicates) { final Predicate<? super T>[] preds = validate(predicates); if (preds.length == 0) { return truePredicate(); } if (preds.length == 1) { return coerce(preds[0]); } return new AllPredicate<>(preds); }
/** * Factory to create the predicate. * <p> * If the array is size zero, the predicate always returns true. * If the array is size one, then that predicate is returned. * * @param <T> the type that the predicate queries * @param predicates the predicates to check, cloned, not null * @return the <code>all</code> predicate * @throws NullPointerException if the predicates array is null * @throws NullPointerException if any predicate in the array is null */ public static <T> Predicate<T> allPredicate(final Predicate<? super T>... predicates) { FunctorUtils.validate(predicates); if (predicates.length == 0) { return truePredicate(); } if (predicates.length == 1) { return coerce(predicates[0]); } return new AllPredicate<>(FunctorUtils.copy(predicates)); }
/** * Create a new Predicate that returns true only if all of the specified * predicates are true. The predicates are checked in iterator order. * If the collection of predicates is empty, then this predicate returns true. * * @param <T> the type that the predicate queries * @param predicates a collection of predicates to check, may not be null * @return the <code>all</code> predicate * @throws NullPointerException if the predicates collection is null * @throws NullPointerException if any predicate in the collection is null * @see AllPredicate */ public static <T> Predicate<T> allPredicate(final Collection<? extends Predicate<? super T>> predicates) { return AllPredicate.allPredicate(predicates); }