Interface Predicate<T>

Type Parameters:
T - the input type
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Predicate<T>
A test of one value.
  • Method Summary

    Modifier and Type
    Method
    Description
    default Predicate<T>
    and(Predicate<? super T> other)
    Passes when this and other both pass; other is not asked when this fails.
    static <T> Predicate<T>
    isEqual(Object targetRef)
    Passes for values equal to targetRef by Object.equals(Object), or for null when targetRef is null.
    default Predicate<T>
    Passes when this fails.
    static <T> Predicate<T>
    not(Predicate<? super T> target)
    The negation of target.
    default Predicate<T>
    or(Predicate<? super T> other)
    Passes when this or other passes; other is not asked when this passes.
    boolean
    test(T t)
    Whether t passes.
  • Method Details

    • test

      boolean test(T t)
      Whether t passes.
      Parameters:
      t - the input
      Returns:
      true when it passes
    • and

      default Predicate<T> and(Predicate<? super T> other)
      Passes when this and other both pass; other is not asked when this fails.
      Parameters:
      other - the second test
      Returns:
      the composed test
    • negate

      default Predicate<T> negate()
      Passes when this fails.
      Returns:
      the negated test
    • or

      default Predicate<T> or(Predicate<? super T> other)
      Passes when this or other passes; other is not asked when this passes.
      Parameters:
      other - the second test
      Returns:
      the composed test
    • isEqual

      static <T> Predicate<T> isEqual(Object targetRef)
      Passes for values equal to targetRef by Object.equals(Object), or for null when targetRef is null.
      Type Parameters:
      T - the input type
      Parameters:
      targetRef - the value to compare with
      Returns:
      the test
    • not

      static <T> Predicate<T> not(Predicate<? super T> target)
      The negation of target.
      Type Parameters:
      T - the input type
      Parameters:
      target - the test to negate
      Returns:
      the negated test