Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8204959

Predicate::not should explicitly mention "NullPointerException - if target is null"

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P3
    • Resolution: Approved
    • Fix Version/s: 11
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Risk:
      minimal
    • Interface Kind:
      Java API

      Description

      Summary

      Report that the method throws a NullPointerException and specify that the method calls the negate method of target argument.

      Problem

      The current Javadoc does not indicate that the method explicitly checks for a null target. Also, the method should indicate that the target Predicate's negate method is called to produce the result.

      Solution

      Update the Javadoc.

      Specification

      /**
       * 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
       *
       * @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();
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jlaskey Jim Laskey
                Reporter:
                dbessono Dmitry Bessonov
                Reviewed By:
                Paul Sandoz (Inactive), Sundararajan Athijegannathan
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: