Package io.vavr.control
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>
and(CheckedPredicate<? super T> that)
Combines this predicate withthat
predicate using logical and (&&).default CheckedPredicate<T>
negate()
Negates this predicate.static <T> CheckedPredicate<T>
not(CheckedPredicate<? super T> that)
Negates a given predicate by callingthat.negate()
.default CheckedPredicate<T>
or(CheckedPredicate<? super T> that)
Combines this predicate withthat
predicate using logical or (||).boolean
test(T t)
Evaluates this predicate on the given argument.
-
-
-
Method Detail
-
not
static <T> CheckedPredicate<T> not(CheckedPredicate<? super T> that)
Negates a given predicate by callingthat.negate()
.- Type Parameters:
T
- argument type ofthat
- Parameters:
that
- a predicate- Returns:
- the negation of the given predicate
that
- Throws:
java.lang.NullPointerException
- if the given predicatethat
is null
-
test
boolean test(T t) throws java.lang.Exception
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.Exception
- if an error occurs
-
and
default CheckedPredicate<T> and(CheckedPredicate<? super T> that)
Combines this predicate withthat
predicate using logical and (&&).- Parameters:
that
- aCheckedPredicate
- Returns:
- a new
CheckedPredicate
withp1.and(p2).test(t) == true :<=> p1.test(t) && p2.test(t) == true
- Throws:
java.lang.NullPointerException
- if the given predicatethat
is null
-
negate
default CheckedPredicate<T> negate()
Negates this predicate.- Returns:
- A new
CheckedPredicate
withp.negate().test(t) == true :<=> p.test(t) == false
-
or
default CheckedPredicate<T> or(CheckedPredicate<? super T> that)
Combines this predicate withthat
predicate using logical or (||).- Parameters:
that
- aCheckedPredicate
- Returns:
- a new
CheckedPredicate
withp1.or(p2).test(t) :<=> p1.test(t) || p2.test(t)
- Throws:
java.lang.NullPointerException
- if the given predicatethat
is null
-
-