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.
@FunctionalInterface public interface CheckedPredicate<T>
A Predicate which may throw.
-
-
Method Summary
Modifier and Type Method Description default CheckedPredicate<T>
negate()
Negates this predicate.static <T> CheckedPredicate<T>
of(CheckedPredicate<T> methodReference)
Creates aCheckedPredicate
.boolean
test(T t)
Evaluates this predicate on the given argument.default java.util.function.Predicate<T>
unchecked()
Returns an uncheckedPredicate
that will sneaky throw if an exceptions occurs when testing a value.
-
-
-
Method Detail
-
of
static <T> CheckedPredicate<T> of(CheckedPredicate<T> methodReference)
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:
CheckedFunction1.of(CheckedFunction1)
-
test
boolean test(T t) throws java.lang.Throwable
Evaluates this predicate on the given argument.- Parameters:
t
- the input argument- Returns:
true
if the input argument matches the predicate, otherwisefalse
- Throws:
java.lang.Throwable
- if an error occurs
-
negate
default CheckedPredicate<T> negate()
Negates this predicate.- Returns:
- A new CheckedPredicate.
-
unchecked
default java.util.function.Predicate<T> unchecked()
Returns an uncheckedPredicate
that will sneaky throw if an exceptions occurs when testing a value.- Returns:
- a new
Predicate
that throws aThrowable
.
-
-