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
    • Scope:
      SE

      Description

      Summary

      A new method isEmpty which would return true if the corresponding Optional does not have a value. Else, it would return false. The proposed method is to be added in Optional, OptionalInt, OptionalDouble and OptionalLong classes.

      Problem

      A method isPresent is available now in Optional, OptionalInt, OptionalDouble and OptionalLong classes. It would be helpful to have its inverse Optional.isEmpty as well.

      Solution

      A new method isEmpty in Optional, OptionalInt, OptionalLong and OptionalDouble classes.

      Specification

      /src/java.base/share/classes/java/util/Optional.java
      
           /**
      +     * If a value is not present, returns {@code true}, otherwise
      +     * {@code false}.
      +     *
      +     * @return  {@code true} if a value is not present, otherwise {@code false}
      +     * @since   11
      +     */
      +    public boolean isEmpty() {
      
      /src/java.base/share/classes/java/util/OptionalDouble.java
      
           /**
      +     * If a value is not present, returns {@code true}, otherwise
      +     * {@code false}.
      +     *
      +     * @return  {@code true} if a value is not present, otherwise {@code false}
      +     * @since   11
      +     */
      +    public boolean isEmpty() {
      
      /src/java.base/share/classes/java/util/OptionalInt.java
      
           /**
      +     * If a value is not present, returns {@code true}, otherwise
      +     * {@code false}.
      +     *
      +     * @return  {@code true} if a value is not present, otherwise {@code false}
      +     * @since   11
      +     */
      +    public boolean isEmpty() {
      
      /src/java.base/share/classes/java/util/OptionalLong.java
      
           /**
      +     * If a value is not present, returns {@code true}, otherwise
      +     * {@code false}.
      +     *
      +     * @return  {@code true} if a value is not present, otherwise {@code false}
      +     * @since   11
      +     */
      +    public boolean isEmpty() {
      
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vtheeyarath Vivek Theeyarath (Inactive)
                Reporter:
                smarks Stuart Marks
                Reviewed By:
                Paul Sandoz (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: