Interface ThrowingPredicate<T>

Type Parameters:
T - type of the input element
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 ThrowingPredicate<T>
This functional interface allows to not catch an Exception in a lambda expression : use it at your own risk, the exception becomes unchecked. It is recommended to use it only in a method that can throw the Exception type that is unchecked. So the exception can be checked when using the method. Source : http://4comprehension.com/sneakily-throwing-exceptions-in-lambda-expressions-in-java/
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    test(T t)
    Redefine the accept method to be able to declare that an exception is thrown
    static <T> Predicate<T>
    Wraps a throwing predicate into a standard unchecked predicate.
  • Method Details

    • test

      boolean test(T t) throws Exception
      Redefine the accept method to be able to declare that an exception is thrown
      Parameters:
      t - the element
      Returns:
      the predicate result
      Throws:
      Exception - if an exception is thrown by the inner method
    • unchecked

      static <T> Predicate<T> unchecked(ThrowingPredicate<T> c)
      Wraps a throwing predicate into a standard unchecked predicate.
      Type Parameters:
      T - type of the input element
      Parameters:
      c - the consumer to call
      Returns:
      the consumer result