Add ifNotPresent to Optional

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Won't Fix
    • Priority: P4
    • None
    • Affects Version/s: 8u20
    • Component/s: core-libs
    • generic
    • generic

      A DESCRIPTION OF THE REQUEST :
      Please add the method similar to the following to java.util.Optional:

          public void ifNotPresent(Runnable cmd) {
              if (value == null)
                  cmd.run();
          }

      JUSTIFICATION :
      While refactoring my codebases to use Java 8 features, I have encountered situations where, I wanted to execute some code that handles the absent of an Optional value.


            Assignee:
            Paul Sandoz
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: