/** * Returns a predicate that evaluates to {@code true} if any of the * component predicates evaluate to {@code true}. The components are * evaluated in order, and evaluation will end upon the first * {@code true} predicate. * * @param <T> the type of values evaluated by the predicates. * @param components The predicates to be evaluated. A copy is made of the * components. * @return A predicate who's result is {@code true} if any component * predicate's result is {@code true}. */ static <T, P extends Predicate<? super T>> Predicate<T> or(final P first, final Iterable<P> components) { final List<P> predicates = safeCopyOf(first, components); return new Predicate<T>() { @Override public boolean test(final T t) { for (final P predicate : predicates) { if (predicate.test(t)) { return true; } } return false; } }; }
/** * Returns a predicate that evaluates to {@code true} if all of the * component predicates evaluate to {@code true}. The components are * evaluated in order, and evaluation will end upon the first * {@code false} predicate. * * @param <T> the type of values evaluated by the predicates. * @param components The predicates to be evaluated. * @return A predicate who's result is {@code true} iff all component * predicates are {@code true}. */ static <T, P extends Predicate<? super T>> Predicate<T> and(final P first, final Iterable<P> components) { final List<P> predicates = safeCopyOf(first, components); return new Predicate<T>() { @Override public boolean test(final T t) { for (final P predicate : predicates) { if (!predicate.test(t)) { return false; } } return true; } }; }
/** * Returns a predicate that evaluates to {@code true} if any of the * component predicates evaluate to {@code true}. The components are * evaluated in order, and evaluation will end upon the first * {@code true} predicate. * * @param <T> the type of values evaluated by the predicates. * @param components The predicates to be evaluated. A copy is made of the * components. * @return A predicate who's result is {@code true} if any component * predicate's result is {@code true}. */ static <T, P extends Predicate<? super T>> Predicate<T> or(final P first, final Iterable<P> components) { final List<P> predicates = safeCopyOf(first, components); return new Predicate<T>() { @Override public boolean test(final T t) { for (final P predicate : predicates) { if (predicate.test(t)) { return true; } } return false; } }; }
/** * Returns a predicate that evaluates to {@code true} if all of the * component predicates evaluate to {@code true}. The components are * evaluated in order, and evaluation will end upon the first * {@code false} predicate. * * @param <T> the type of values evaluated by the predicates. * @param components The predicates to be evaluated. * @return A predicate who's result is {@code true} iff all component * predicates are {@code true}. */ static <T, P extends Predicate<? super T>> Predicate<T> and(final P first, final Iterable<P> components) { final List<P> predicates = safeCopyOf(first, components); return new Predicate<T>() { @Override public boolean test(final T t) { for (final P predicate : predicates) { if (!predicate.test(t)) { return false; } } return true; } }; }
/** * Returns a predicate that evaluates to {@code true} if any of the * component predicates evaluate to {@code true}. The components are * evaluated in order, and evaluation will end upon the first * {@code true} predicate. * * @param <T> the type of values evaluated by the predicates. * @param components The predicates to be evaluated. A copy is made of the * components. * @return A predicate who's result is {@code true} if any component * predicate's result is {@code true}. */ static <T, P extends Predicate<? super T>> Predicate<T> or(final P first, final Iterable<P> components) { final List<P> predicates = safeCopyOf(first, components); return new Predicate<T>() { @Override public boolean test(final T t) { for (final P predicate : predicates) { if (predicate.test(t)) { return true; } } return false; } }; }
/** * Returns a predicate that evaluates to {@code true} if all of the * component predicates evaluate to {@code true}. The components are * evaluated in order, and evaluation will end upon the first * {@code false} predicate. * * @param <T> the type of values evaluated by the predicates. * @param components The predicates to be evaluated. * @return A predicate who's result is {@code true} iff all component * predicates are {@code true}. */ static <T, P extends Predicate<? super T>> Predicate<T> and(final P first, final Iterable<P> components) { final List<P> predicates = safeCopyOf(first, components); return new Predicate<T>() { @Override public boolean test(final T t) { for (final P predicate : predicates) { if (!predicate.test(t)) { return false; } } return true; } }; }
/** * Returns a predicate that evaluates to {@code true} if any of the * component predicates evaluate to {@code true}. The components are * evaluated in order, and evaluation will terminate upon the first * {@code true} predicate. * * @param <T> the type of values evaluated by the predicates. * @param components The predicates to be evaluated. A copy is made of the * components. * @return A predicate who's result is {@code true} if any component * predicate's result is {@code true}. */ @SafeVarargs static <T, P extends Predicate<? super T>> Predicate<T> or(final Predicate<T> first, final P... components) { final P[] predicates = safeCopyOf((P) first, components); return new Predicate<T>() { @Override public boolean test(final T t) { for (final P predicate : predicates) { if (predicate.test(t)) { return true; } } return false; } }; }
/** * Returns a predicate that evaluates to {@code true} if any of the * component predicates evaluate to {@code true}. The components are * evaluated in order, and evaluation will terminate upon the first * {@code true} predicate. * * @param <T> the type of values evaluated by the predicates. * @param components The predicates to be evaluated. A copy is made of the * components. * @return A predicate who's result is {@code true} if any component * predicate's result is {@code true}. */ @SafeVarargs static <T, P extends Predicate<? super T>> Predicate<T> or(final Predicate<T> first, final P... components) { final P[] predicates = safeCopyOf((P) first, components); return new Predicate<T>() { @Override public boolean test(final T t) { for (final P predicate : predicates) { if (predicate.test(t)) { return true; } } return false; } }; }
/** * Returns a predicate that evaluates to {@code true} if any of the * component predicates evaluate to {@code true}. The components are * evaluated in order, and evaluation will terminate upon the first * {@code true} predicate. * * @param <T> the type of values evaluated by the predicates. * @param components The predicates to be evaluated. A copy is made of the * components. * @return A predicate who's result is {@code true} if any component * predicate's result is {@code true}. */ @SafeVarargs static <T, P extends Predicate<? super T>> Predicate<T> or(final Predicate<T> first, final P... components) { final P[] predicates = safeCopyOf((P) first, components); return new Predicate<T>() { @Override public boolean test(final T t) { for (final P predicate : predicates) { if (predicate.test(t)) { return true; } } return false; } }; }
final P[] predicates = safeCopyOf((P) first, components);
/** * Returns a predicate that evaluates to {@code true} if any of the * component predicates evaluate to {@code true}. The components are * evaluated in order, and evaluation will terminate upon the first * {@code true} predicate. * * @param <T> the type of values evaluated by the predicates. * @param components The predicates to be evaluated. A copy is made of the * components. * @return A predicate who's result is {@code true} if any component * predicate's result is {@code true}. */ @SafeVarargs public static <T, P extends Predicate<? super T>> Predicate<T> or(final P... components) { final P[] predicates = safeCopyOf(components); if(0 == predicates.length) { throw new IllegalArgumentException("no predicates"); } return new Predicate<T>() { @Override public boolean test(final T t) { for (final P predicate : predicates) { if (predicate.test(t)) { return true; } } return false; } }; }
/** * Returns a predicate that evaluates to {@code true} if any of the * component predicates evaluate to {@code true}. The components are * evaluated in order, and evaluation will end upon the first * {@code true} predicate. * * @param <T> the type of values evaluated by the predicates. * @param components The predicates to be evaluated. A copy is made of the * components. * @return A predicate who's result is {@code true} if any component * predicate's result is {@code true}. */ public static <T, P extends Predicate<? super T>> Predicate<T> or(final Iterable<P> components) { final List<P> predicates = safeCopyOf(components); if(predicates.isEmpty()) { throw new IllegalArgumentException("no predicates"); } return new Predicate<T>() { @Override public boolean test(final T t) { for (final P predicate : predicates) { if (predicate.test(t)) { return true; } } return false; } }; }
/** * Returns a predicate that evaluates to {@code true} if any of the * component predicates evaluate to {@code true}. The components are * evaluated in order, and evaluation will end upon the first * {@code true} predicate. * * @param <T> the type of values evaluated by the predicates. * @param components The predicates to be evaluated. A copy is made of the * components. * @return A predicate who's result is {@code true} if any component * predicate's result is {@code true}. */ public static <T, P extends Predicate<? super T>> Predicate<T> or(final Iterable<P> components) { final List<P> predicates = safeCopyOf(components); if(predicates.isEmpty()) { throw new IllegalArgumentException("no predicates"); } return new Predicate<T>() { @Override public boolean test(final T t) { for (final P predicate : predicates) { if (predicate.test(t)) { return true; } } return false; } }; }
final P[] predicates = safeCopyOf(first, components);
/** * Returns a predicate that evaluates to {@code true} if all of the * component predicates evaluate to {@code true}. The components are * evaluated in order, and evaluation will end upon the first * {@code false} predicate. * * @param <T> the type of values evaluated by the predicates. * @param components The predicates to be evaluated. * @return A predicate who's result is {@code true} iff all component * predicates are {@code true}. */ public static <T, P extends Predicate<? super T>> Predicate<T> and(final Iterable<P> components) { final List<P> predicates = safeCopyOf(components); if(predicates.isEmpty()) { throw new IllegalArgumentException("no predicates"); } return new Predicate<T>() { @Override public boolean test(final T t) { for (final P predicate : predicates) { if (!predicate.test(t)) { return false; } } return true; } }; }
final P[] predicates = safeCopyOf(first, components);
/** * Returns a predicate that evaluates to {@code true} if all of the * component predicates evaluate to {@code true}. The components are * evaluated in order, and evaluation will end upon the first * {@code false} predicate. * * @param <T> the type of values evaluated by the predicates. * @param components The predicates to be evaluated. A copy is made of the * components. * @return A predicate who's result is {@code true} iff all component * predicates are {@code true}. */ @SafeVarargs public static <T, P extends Predicate<? super T>> Predicate<T> and(final P... components) { final P[] predicates = safeCopyOf(components); if(0 == predicates.length) { throw new IllegalArgumentException("no predicates"); } return new Predicate<T>() { @Override public boolean test(final T t) { for (final P predicate : predicates) { if (!predicate.test(t)) { return false; } } return true; } }; }
/** * Returns a predicate that evaluates to {@code true} if any of the * component predicates evaluate to {@code true}. The components are * evaluated in order, and evaluation will end upon the first * {@code true} predicate. * * @param <T> the type of values evaluated by the predicates. * @param components The predicates to be evaluated. A copy is made of the * components. * @return A predicate who's result is {@code true} if any component * predicate's result is {@code true}. */ public static <T, P extends Predicate<? super T>> Predicate<T> or(final Iterable<P> components) { final List<P> predicates = safeCopyOf(components); if(predicates.isEmpty()) { throw new IllegalArgumentException("no predicates"); } return new Predicate<T>() { @Override public boolean test(final T t) { for (final P predicate : predicates) { if (predicate.test(t)) { return true; } } return false; } }; }
/** * Returns a predicate that evaluates to {@code true} if any of the * component predicates evaluate to {@code true}. The components are * evaluated in order, and evaluation will terminate upon the first * {@code true} predicate. * * @param <T> the type of values evaluated by the predicates. * @param components The predicates to be evaluated. A copy is made of the * components. * @return A predicate who's result is {@code true} if any component * predicate's result is {@code true}. */ @SafeVarargs public static <T, P extends Predicate<? super T>> Predicate<T> or(final P... components) { final P[] predicates = safeCopyOf(components); if(0 == predicates.length) { throw new IllegalArgumentException("no predicates"); } return new Predicate<T>() { @Override public boolean test(final T t) { for (final P predicate : predicates) { if (predicate.test(t)) { return true; } } return false; } }; }
/** * Returns a predicate that evaluates to {@code true} if all of the * component predicates evaluate to {@code true}. The components are * evaluated in order, and evaluation will end upon the first * {@code false} predicate. * * @param <T> the type of values evaluated by the predicates. * @param components The predicates to be evaluated. A copy is made of the * components. * @return A predicate who's result is {@code true} iff all component * predicates are {@code true}. */ @SafeVarargs public static <T, P extends Predicate<? super T>> Predicate<T> and(final P... components) { final P[] predicates = safeCopyOf(components); if(0 == predicates.length) { throw new IllegalArgumentException("no predicates"); } return new Predicate<T>() { @Override public boolean test(final T t) { for (final P predicate : predicates) { if (!predicate.test(t)) { return false; } } return true; } }; }