@FunctionalInterface public interface ThrowingPredicate<T> extends Predicate<T>
boolean-valued function) of one argument, possibly throwing an exception.| Modifier and Type | Method and Description |
|---|---|
default Predicate<T> |
fallbackTo(Predicate<T> fallback)
Returns a
Predicate evaluating the given predicate on the argument if this predicate throws an exception. |
default Predicate<T> |
fallbackTo(Predicate<T> fallback,
Consumer<Exception> exceptionConsumer)
Returns a
Predicate evaluating the given predicate on the argument if this predicate throws an exception. |
default Predicate<T> |
orReturn(boolean value)
Returns a
Predicate returning the given value if this predicate throws an exception. |
default Predicate<T> |
orReturn(boolean value,
Consumer<Exception> exceptionConsumer)
Returns a
Predicate returning the given value if this predicate throws an exception. |
default ThrowingPredicate<T> |
orThrow(Class<? extends RuntimeException> exceptionClass)
Returns a
ThrowingPredicate throwing an exception of the given type if this predicate throws an exception. |
default ThrowingPredicate<T> |
orThrow(Class<? extends RuntimeException> exceptionClass,
String message)
Returns a
ThrowingPredicate throwing an exception of the given type if this predicate throws an exception. |
default ThrowingPredicate<T> |
orTryWith(ThrowingPredicate<? super T> other)
Returns a
ThrowingPredicate evaluating the given predicate on the argument if this predicate throws an exception. |
default ThrowingPredicate<T> |
orTryWith(ThrowingPredicate<? super T> other,
Consumer<Exception> exceptionConsumer)
Returns a
ThrowingPredicate evaluating the given predicate on the argument if this predicate throws an exception. |
default boolean |
test(T argument)
Evaluates this predicate on the given argument.
|
boolean |
testThrowing(T argument)
Evaluates this predicate on the given argument.
|
default boolean test(T argument)
UncheckedException.boolean testThrowing(T argument) throws Exception
Exceptiondefault Predicate<T> fallbackTo(Predicate<T> fallback)
Predicate evaluating the given predicate on the argument if this predicate throws an exception.IllegalArgumentException - if fallback is nulldefault Predicate<T> fallbackTo(Predicate<T> fallback, Consumer<Exception> exceptionConsumer)
Predicate evaluating the given predicate on the argument if this predicate throws an exception.IllegalArgumentException - if fallback is nulldefault Predicate<T> orReturn(boolean value)
Predicate returning the given value if this predicate throws an exception.default Predicate<T> orReturn(boolean value, Consumer<Exception> exceptionConsumer)
Predicate returning the given value if this predicate throws an exception.default ThrowingPredicate<T> orThrow(Class<? extends RuntimeException> exceptionClass)
ThrowingPredicate throwing an exception of the given type if this predicate throws an exception.
The original exception thrown by this predicate is the cause of the thrown exception.
The exception class must have a constructor accepting a single Throwable as an argument.
IllegalArgumentException - if exceptionClass is nulldefault ThrowingPredicate<T> orThrow(Class<? extends RuntimeException> exceptionClass, String message)
ThrowingPredicate throwing an exception of the given type if this predicate throws an exception.
The original exception thrown by this predicate is the cause of the thrown exception.
The exception class must have a constructor accepting String and Throwable as arguments.
IllegalArgumentException - if exceptionClass is nulldefault ThrowingPredicate<T> orTryWith(ThrowingPredicate<? super T> other)
ThrowingPredicate evaluating the given predicate on the argument if this predicate throws an exception.IllegalArgumentException - if other is nulldefault ThrowingPredicate<T> orTryWith(ThrowingPredicate<? super T> other, Consumer<Exception> exceptionConsumer)
ThrowingPredicate evaluating the given predicate on the argument if this predicate throws an exception.IllegalArgumentException - if other is null