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.
@ConsumerType @FunctionalInterface public interface Predicate<T>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.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Predicate<T>and(Predicate<? super T> and)Compose thisPredicatelogical-AND the specifiedPredicate.static <T> java.util.function.Predicate<T>asJavaPredicate(Predicate<T> wrapped)Returns ajava.util.function.Predicatewhich wraps the specifiedPredicateand throws any thrown exceptions.static <T> java.util.function.Predicate<T>asJavaPredicateOrElse(Predicate<T> wrapped, boolean orElse)Returns ajava.util.function.Predicatewhich wraps the specifiedPredicateand the specified value.static <T> java.util.function.Predicate<T>asJavaPredicateOrElseGet(Predicate<T> wrapped, java.util.function.BooleanSupplier orElseGet)Returns ajava.util.function.Predicatewhich wraps the specifiedPredicateand the specifiedjava.util.function.BooleanSupplier.static <T> Predicate<T>asPredicate(java.util.function.Predicate<T> wrapped)Returns aPredicatewhich wraps the specifiedjava.util.function.Predicate.default Predicate<T>negate()Return aPredicatewhich is the negation of thisPredicate.default Predicate<T>or(Predicate<? super T> or)Compose thisPredicatelogical-OR the specifiedPredicate.booleantest(T t)Evaluates this predicate on the specified argument.
-
-
-
Method Detail
-
test
boolean test(T t) throws java.lang.Exception
Evaluates this predicate on the specified argument.- Parameters:
t- The input to this predicate.- Returns:
trueif the specified argument is accepted by this predicate;falseotherwise.- Throws:
java.lang.Exception- An exception thrown by the method.
-
negate
default Predicate<T> negate()
Return aPredicatewhich is the negation of thisPredicate.- Returns:
- A
Predicatewhich is the negation of thisPredicate.
-
and
default Predicate<T> and(Predicate<? super T> and)
Compose thisPredicatelogical-AND the specifiedPredicate.Short-circuiting is used, so the specified
Predicateis not called if thisPredicatereturnsfalse.- Parameters:
and- ThePredicateto be called after thisPredicateis called. Must not benull.- Returns:
- A
Predicatecomposed of thisPredicateand the specifiedPredicateusing logical-AND.
-
or
default Predicate<T> or(Predicate<? super T> or)
Compose thisPredicatelogical-OR the specifiedPredicate.Short-circuiting is used, so the specified
Predicateis not called if thisPredicatereturnstrue.- Parameters:
or- ThePredicateto be called after thisPredicateis called. Must not benull.- Returns:
- A
Predicatecomposed of thisPredicateand the specifiedPredicateusing logical-OR.
-
asJavaPredicate
static <T> java.util.function.Predicate<T> asJavaPredicate(Predicate<T> wrapped)
Returns ajava.util.function.Predicatewhich wraps the specifiedPredicateand throws any thrown exceptions.The returned
java.util.function.Predicatewill throw any exception thrown by the wrappedPredicate.- Type Parameters:
T- The type of the predicate input.- Parameters:
wrapped- ThePredicateto wrap. Must not benull.- Returns:
- A
java.util.function.Predicatewhich wraps the specifiedPredicate.
-
asJavaPredicateOrElse
static <T> java.util.function.Predicate<T> asJavaPredicateOrElse(Predicate<T> wrapped, boolean orElse)
Returns ajava.util.function.Predicatewhich wraps the specifiedPredicateand the specified value.If the the specified
Predicatethrows anException, the the specified value is returned.- Type Parameters:
T- The type of the predicate input.- Parameters:
wrapped- ThePredicateto wrap. Must not benull.orElse- The value to return if the specifiedPredicatethrows anException.- Returns:
- A
java.util.function.Predicatewhich wraps the specifiedPredicateand the specified value.
-
asJavaPredicateOrElseGet
static <T> java.util.function.Predicate<T> asJavaPredicateOrElseGet(Predicate<T> wrapped, java.util.function.BooleanSupplier orElseGet)
Returns ajava.util.function.Predicatewhich wraps the specifiedPredicateand the specifiedjava.util.function.BooleanSupplier.If the the specified
Predicatethrows anException, the value returned by the specifiedjava.util.function.BooleanSupplieris returned.- Type Parameters:
T- The type of the predicate input.- Parameters:
wrapped- ThePredicateto wrap. Must not benull.orElseGet- Thejava.util.function.BooleanSupplierto call for a return value if the specifiedPredicatethrows anException.- Returns:
- A
java.util.function.Predicatewhich wraps the specifiedPredicateand the specifiedjava.util.function.BooleanSupplier.
-
asPredicate
static <T> Predicate<T> asPredicate(java.util.function.Predicate<T> wrapped)
Returns aPredicatewhich wraps the specifiedjava.util.function.Predicate.- Type Parameters:
T- The type of the predicate input.- Parameters:
wrapped- Thejava.util.function.Predicateto wrap. Must not benull.- Returns:
- A
Predicatewhich wraps the specifiedjava.util.function.Predicate.
-
-