Class AndPredicate<T>

  • Type Parameters:
    T - the type of the input to the predicate.
    All Implemented Interfaces:
    java.io.Serializable, java.util.function.Predicate<T>, PredicateDecorator<T>, Predicate<T>

    public final class AndPredicate<T>
    extends AbstractPredicate<T>
    implements PredicateDecorator<T>, java.io.Serializable
    Predicate implementation that returns true if both the predicates return true.
    Since:
    3.0
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      AndPredicate​(Predicate<? super T> predicate1, Predicate<? super T> predicate2)
      Constructor that performs no validation.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> Predicate<T> andPredicate​(Predicate<? super T> predicate1, Predicate<? super T> predicate2)
      Creates the predicate.
      Predicate<? super T>[] getPredicates()
      Gets the two predicates being decorated as an array.
      boolean test​(T object)
      Evaluates the predicate returning true if both predicates return true.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.function.Predicate

        and, negate, or
    • Constructor Detail

      • AndPredicate

        public AndPredicate​(Predicate<? super T> predicate1,
                            Predicate<? super T> predicate2)
        Constructor that performs no validation. Use andPredicate if you want that.
        Parameters:
        predicate1 - the first predicate to check, not null
        predicate2 - the second predicate to check, not null
    • Method Detail

      • andPredicate

        public static <T> Predicate<T> andPredicate​(Predicate<? super T> predicate1,
                                                    Predicate<? super T> predicate2)
        Creates the predicate.
        Type Parameters:
        T - the type that the predicate queries
        Parameters:
        predicate1 - the first predicate to check, not null
        predicate2 - the second predicate to check, not null
        Returns:
        the and predicate
        Throws:
        java.lang.NullPointerException - if either predicate is null
      • getPredicates

        public Predicate<? super T>[] getPredicates()
        Gets the two predicates being decorated as an array.
        Specified by:
        getPredicates in interface PredicateDecorator<T>
        Returns:
        the predicates
        Since:
        3.1
      • test

        public boolean test​(T object)
        Evaluates the predicate returning true if both predicates return true.
        Specified by:
        test in interface java.util.function.Predicate<T>
        Specified by:
        test in interface Predicate<T>
        Parameters:
        object - the input object
        Returns:
        true if both decorated predicates return true