java.util.Optional should have a "T orNull()"

XMLWordPrintable

      A DESCRIPTION OF THE REQUEST :
      There is orElse(T), but it shall have an orNull() too.

      JUSTIFICATION :
      If a null value is ok, orElse(null) is the cheapest way today.

      When doing annotation base null analysis, this is bad, because I cannot mark orElse as returning non-null.
      When there would be orNull(), for null analysis i could annotate like this:

      @NonNull T orElse( @NonNull T t )
      @Nullable T orNull()






            Assignee:
            Stuart Marks
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: