Package org.osgi.util.function
Interface Predicate<T>
- Type Parameters:
T
- The type of the predicate input.
- 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 accepts a single argument and produces a boolean result.
This is a functional interface and can be used as the assignment target for a lambda expression or method reference.
- "ThreadSafe"
-
Method Summary
Modifier and TypeMethodDescriptionCompose thisPredicate
logical-AND the specifiedPredicate
.static <T> Predicate<T>
asJavaPredicate
(Predicate<T> wrapped) Returns ajava.util.function.Predicate
which wraps the specifiedPredicate
and throws any thrown exceptions.static <T> Predicate<T>
asJavaPredicateOrElse
(Predicate<T> wrapped, boolean orElse) Returns ajava.util.function.Predicate
which wraps the specifiedPredicate
and the specified value.static <T> Predicate<T>
asJavaPredicateOrElseGet
(Predicate<T> wrapped, BooleanSupplier orElseGet) Returns ajava.util.function.Predicate
which wraps the specifiedPredicate
and the specifiedjava.util.function.BooleanSupplier
.static <T> Predicate<T>
asPredicate
(Predicate<T> wrapped) Returns aPredicate
which wraps the specifiedjava.util.function.Predicate
.negate()
Return aPredicate
which is the negation of thisPredicate
.Compose thisPredicate
logical-OR the specifiedPredicate
.boolean
Evaluates this predicate on the specified argument.
-
Method Details
-
test
Evaluates this predicate on the specified argument.- Parameters:
t
- The input to this predicate.- Returns:
true
if the specified argument is accepted by this predicate;false
otherwise.- Throws:
Exception
- An exception thrown by the method.
-
negate
Return aPredicate
which is the negation of thisPredicate
.- Returns:
- A
Predicate
which is the negation of thisPredicate
.
-
and
Compose thisPredicate
logical-AND the specifiedPredicate
.Short-circuiting is used, so the specified
Predicate
is not called if thisPredicate
returnsfalse
.- Parameters:
and
- ThePredicate
to be called after thisPredicate
is called. Must not benull
.- Returns:
- A
Predicate
composed of thisPredicate
and the specifiedPredicate
using logical-AND.
-
or
Compose thisPredicate
logical-OR the specifiedPredicate
.Short-circuiting is used, so the specified
Predicate
is not called if thisPredicate
returnstrue
.- Parameters:
or
- ThePredicate
to be called after thisPredicate
is called. Must not benull
.- Returns:
- A
Predicate
composed of thisPredicate
and the specifiedPredicate
using logical-OR.
-
asJavaPredicate
Returns ajava.util.function.Predicate
which wraps the specifiedPredicate
and throws any thrown exceptions.The returned
java.util.function.Predicate
will throw any exception thrown by the wrappedPredicate
.- Type Parameters:
T
- The type of the predicate input.- Parameters:
wrapped
- ThePredicate
to wrap. Must not benull
.- Returns:
- A
java.util.function.Predicate
which wraps the specifiedPredicate
.
-
asJavaPredicateOrElse
Returns ajava.util.function.Predicate
which wraps the specifiedPredicate
and the specified value.If the the specified
Predicate
throws anException
, the the specified value is returned.- Type Parameters:
T
- The type of the predicate input.- Parameters:
wrapped
- ThePredicate
to wrap. Must not benull
.orElse
- The value to return if the specifiedPredicate
throws anException
.- Returns:
- A
java.util.function.Predicate
which wraps the specifiedPredicate
and the specified value.
-
asJavaPredicateOrElseGet
Returns ajava.util.function.Predicate
which wraps the specifiedPredicate
and the specifiedjava.util.function.BooleanSupplier
.If the the specified
Predicate
throws anException
, the value returned by the specifiedjava.util.function.BooleanSupplier
is returned.- Type Parameters:
T
- The type of the predicate input.- Parameters:
wrapped
- ThePredicate
to wrap. Must not benull
.orElseGet
- Thejava.util.function.BooleanSupplier
to call for a return value if the specifiedPredicate
throws anException
.- Returns:
- A
java.util.function.Predicate
which wraps the specifiedPredicate
and the specifiedjava.util.function.BooleanSupplier
.
-
asPredicate
Returns aPredicate
which wraps the specifiedjava.util.function.Predicate
.- Type Parameters:
T
- The type of the predicate input.- Parameters:
wrapped
- Thejava.util.function.Predicate
to wrap. Must not benull
.- Returns:
- A
Predicate
which wraps the specifiedjava.util.function.Predicate
.
-