Package io.vavr
Interface CheckedPredicate<T>
- Type Parameters:
T
- the type of the input to the predicate
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A Predicate which may throw.
-
Method Summary
Modifier and TypeMethodDescriptiondefault CheckedPredicate
<T> negate()
Negates this predicate.static <T> CheckedPredicate
<T> of
(CheckedPredicate<T> methodReference) Creates aCheckedPredicate
.boolean
Evaluates this predicate on the given argument.Returns an uncheckedPredicate
that will sneaky throw if an exceptions occurs when testing a value.
-
Method Details
-
of
Creates aCheckedPredicate
.final CheckedPredicate<Boolean> checkedPredicate = CheckedPredicate.of(Boolean::booleanValue); final Predicate<Boolean> predicate = checkedPredicate.unchecked(); // = true predicate.test(Boolean.TRUE); // throws predicate.test(null);
- Type Parameters:
T
- type of values that are tested by the predicate- Parameters:
methodReference
- (typically) a method reference, e.g.Type::method
- Returns:
- a new
CheckedPredicate
- See Also:
-
test
Evaluates this predicate on the given argument.- Parameters:
t
- the input argument- Returns:
true
if the input argument matches the predicate, otherwisefalse
- Throws:
Throwable
- if an error occurs
-
negate
Negates this predicate.- Returns:
- A new CheckedPredicate.
-
unchecked
Returns an uncheckedPredicate
that will sneaky throw if an exceptions occurs when testing a value.- Returns:
- a new
Predicate
that throws aThrowable
.
-