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

add Comparator factory methods for explicit values

XMLWordPrintable

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

      There should be static factory methods on Comparator that create Comparator instances from an explicit list of values (varargs) or from a collection of such values (which must have a defined order, of course).

      There should be variations where the explicit values are ordered first, or last, or that generate an exception. For the order-first and -last variations, a downstream comparator should be provided to order any non-matching values.

      public static <T> Comparator<T> explicitFirst(Comparator<? super T> comparator, T first, T... rest)

      public static <T> Comparator<T> explicitLast(Comparator<? super T> comparator, T first, T... rest)

      public static <T> Comparator<T> explicitFirst(Comparator<? super T> comparator, Collection<? extends T> coll)

      public static <T> Comparator<T> explicitLast(Comparator<? super T> comparator, Collection<? extends T> coll)

      public static <T> Comparator<T> explicit(T first, T... rest)

      public static <T> Comparator<T> explicit(Collection<? extends T> coll)

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

              Created:
              Updated: