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 that is allowed to throw checked exceptions.
-
Method Summary
Modifier and TypeMethodDescriptiondefault CheckedPredicate<T> negate()Returns a predicate that represents the logical negation of this predicate.static <T> CheckedPredicate<T> of(@NonNull CheckedPredicate<T> methodReference) Creates aCheckedPredicatefrom the given method reference or lambda.booleanEvaluates this predicate on the given argument.Returns an uncheckedPredicatethat sneakily throws any exception encountered when testing a value.
-
Method Details
-
of
Creates aCheckedPredicatefrom the given method reference or lambda.Example usage:
final CheckedPredicate<Boolean> checkedPredicate = CheckedPredicate.of(Boolean::booleanValue); final Predicate<Boolean> predicate = checkedPredicate.unchecked(); // returns true predicate.test(Boolean.TRUE); // may throw an exception predicate.test(null);- Type Parameters:
T- the type of values tested by the predicate- Parameters:
methodReference- typically a method reference, e.g.Type::method- Returns:
- a new
CheckedPredicatewrapping the given method reference - See Also:
-
test
Evaluates this predicate on the given argument.- Parameters:
t- the input argument- Returns:
trueif the argument satisfies the predicate,falseotherwise- Throws:
Throwable- if an error occurs during evaluation
-
negate
Returns a predicate that represents the logical negation of this predicate.- Returns:
- a new
CheckedPredicaterepresenting the negated condition
-
unchecked
Returns an uncheckedPredicatethat sneakily throws any exception encountered when testing a value.
-