mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8050818: Predicate::not - provide an easier way to negate a predicate
Reviewed-by: chegar, dl, psandoz, forax, smarks, redestad
This commit is contained in:
parent
0084eebd36
commit
e18f24a98e
2 changed files with 84 additions and 0 deletions
|
@ -116,4 +116,20 @@ public interface Predicate<T> {
|
|||
? Objects::isNull
|
||||
: object -> targetRef.equals(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a predicate that is the negation of the supplied predicate.
|
||||
*
|
||||
* @param <T> the type of arguments to the specified predicate
|
||||
* @param target predicate to negate
|
||||
*
|
||||
* @return a predicate that negates the results of the supplied
|
||||
* predicate
|
||||
*
|
||||
* @since 11
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
static <T> Predicate<T> not(Predicate<? super T> target) {
|
||||
return (Predicate<T>)target.negate();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue