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

(opt) add Optional.compare

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • core-libs

      Add a comparison method to Optional. This should have overloads that take a comparator or rely on the contained objects to be comparable. There should also be a way to sort empty Optionals first or last. For example:

      static <T> int compare(Optional<? extends T> a, Optional<? extends T> b, boolean emptyFirst, Comparator<T> cmp)

      static <T extends Comparable<? super T>>
          int compare(Optional<? extends T> a, Optional<? extends T> b, boolean emptyFirst)

            smarks Stuart Marks
            smarks Stuart Marks
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: