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
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default CheckedPredicate<T>negate()Negates this predicate.static <T> CheckedPredicate<T>of(CheckedPredicate<T> methodReference)Creates aCheckedPredicate.booleantest(T t)Evaluates this predicate on the given argument.default java.util.function.Predicate<T>unchecked()Returns an uncheckedPredicatethat 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:
trueif 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 uncheckedPredicatethat will sneaky throw if an exceptions occurs when testing a value.- Returns:
- a new
Predicatethat throws aThrowable.
-
-