8204172: Predicate::not should explicitly mention "NullPointerException - if target is null"
authorjlaskey
Thu, 14 Jun 2018 09:38:31 -0300
changeset 50567 9ee93487d262
parent 50566 c0b896fc3f08
child 50568 0f807f558017
8204172: Predicate::not should explicitly mention "NullPointerException - if target is null" Reviewed-by: sundar, psandoz, dfuchs
src/java.base/share/classes/java/util/function/Predicate.java
--- a/src/java.base/share/classes/java/util/function/Predicate.java	Thu Jun 14 13:16:21 2018 +0200
+++ b/src/java.base/share/classes/java/util/function/Predicate.java	Thu Jun 14 09:38:31 2018 -0300
@@ -119,6 +119,8 @@
 
     /**
      * Returns a predicate that is the negation of the supplied predicate.
+     * This is accomplished by returning result of the calling
+     * {@code target.negate()}.
      *
      * @param <T>     the type of arguments to the specified predicate
      * @param target  predicate to negate
@@ -126,10 +128,13 @@
      * @return a predicate that negates the results of the supplied
      *         predicate
      *
+     * @throws NullPointerException if target is null
+     *
      * @since 11
      */
     @SuppressWarnings("unchecked")
     static <T> Predicate<T> not(Predicate<? super T> target) {
+        Objects.requireNonNull(target);
         return (Predicate<T>)target.negate();
     }
 }