Class AllPredicate<T>

  • All Implemented Interfaces:
    java.io.Serializable, PredicateDecorator<T>, Predicate<T>

    public final class AllPredicate<T>
    extends AbstractQuantifierPredicate<T>
    Predicate implementation that returns true if all the predicates return true. If the array of predicates is empty, then this predicate returns true.

    NOTE: In versions prior to 3.2 an array size of zero or one threw an exception.

    Since:
    3.0
    See Also:
    Serialized Form
    • Constructor Detail

      • AllPredicate

        public AllPredicate​(Predicate<? super T>... predicates)
        Constructor that performs no validation. Use allPredicate if you want that.
        Parameters:
        predicates - the predicates to check, not cloned, not null
    • Method Detail

      • allPredicate

        public static <T> Predicate<T> allPredicate​(Predicate<? super T>... predicates)
        Factory to create the predicate.

        If the array is size zero, the predicate always returns true. If the array is size one, then that predicate is returned.

        Type Parameters:
        T - the type that the predicate queries
        Parameters:
        predicates - the predicates to check, cloned, not null
        Returns:
        the all predicate
        Throws:
        java.lang.NullPointerException - if the predicates array is null
        java.lang.NullPointerException - if any predicate in the array is null
      • allPredicate

        public static <T> Predicate<T> allPredicate​(java.util.Collection<? extends Predicate<? super T>> predicates)
        Factory to create the predicate.

        If the collection is size zero, the predicate always returns true. If the collection is size one, then that predicate is returned.

        Type Parameters:
        T - the type that the predicate queries
        Parameters:
        predicates - the predicates to check, cloned, not null
        Returns:
        the all predicate
        Throws:
        java.lang.NullPointerException - if the predicates array is null
        java.lang.NullPointerException - if any predicate in the array is null
      • evaluate

        public boolean evaluate​(T object)
        Evaluates the predicate returning true if all predicates return true.
        Parameters:
        object - the input object
        Returns:
        true if all decorated predicates return true