/** * Factory to create the predicate. * * @param <T> the type that the predicate queries * @param predicates the predicates to check, cloned, not null * @return the <code>one</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> onePredicate(final Collection<? extends Predicate<? super T>> predicates) { final Predicate<? super T>[] preds = FunctorUtils.validate(predicates); return new OnePredicate<>(preds); }
/** * Factory to create the predicate. * <p> * If the array is size zero, the predicate always returns false. * 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>any</code> predicate * @throws NullPointerException if the predicates array is null * @throws NullPointerException if any predicate in the array is null */ @SuppressWarnings("unchecked") public static <T> Predicate<T> onePredicate(final Predicate<? super T>... predicates) { FunctorUtils.validate(predicates); if (predicates.length == 0) { return FalsePredicate.<T>falsePredicate(); } if (predicates.length == 1) { return (Predicate<T>) predicates[0]; } return new OnePredicate<>(FunctorUtils.copy(predicates)); }