Interface ComparatorEx<T>

  • Type Parameters:
    T - the type of objects that may be compared by this comparator
    All Superinterfaces:
    java.util.Comparator<T>, java.io.Serializable
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface ComparatorEx<T>
    extends java.util.Comparator<T>, java.io.Serializable
    Serializable variant of java.util.Comparator which declares checked exception.
    Since:
    4.0
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default int compare​(T o1, T o2)  
      int compareEx​(T o1, T o2)
      Exception-declaring version of Comparator.compare(T, T).
      static <T,​U extends java.lang.Comparable<? super U>>
      ComparatorEx<T>
      comparing​(FunctionEx<? super T,​? extends U> toKeyFn)
      Serializable variant of java.util.Comparator#comparing(Function).
      static <T,​U>
      ComparatorEx<T>
      comparing​(FunctionEx<? super T,​? extends U> toKeyFn, ComparatorEx<? super U> keyComparator)
      Serializable variant of java.util.Comparator#comparing(Function, Comparator).
      static <T,​U extends java.lang.Comparable<? super U>>
      ComparatorEx<T>
      comparing​(java.util.function.Function<? super T,​? extends U> toKeyFn)
      Serializable variant of java.util.Comparator#comparing(Function).
      static <T,​U>
      ComparatorEx<T>
      comparing​(java.util.function.Function<? super T,​? extends U> toKeyFn, java.util.Comparator<? super U> keyComparator)
      Serializable variant of java.util.Comparator#comparing(Function, Comparator).
      static <T> ComparatorEx<T> comparingDouble​(ToDoubleFunctionEx<? super T> toKeyFn)
      Serializable variant of java.util.Comparator#comparingDouble(ToDoubleFunction).
      static <T> ComparatorEx<T> comparingDouble​(java.util.function.ToDoubleFunction<? super T> toKeyFn)
      Serializable variant of java.util.Comparator#comparingDouble(ToDoubleFunction).
      static <T> ComparatorEx<T> comparingInt​(ToIntFunctionEx<? super T> toKeyFn)
      Serializable variant of java.util.Comparator#comparingInt(ToIntFunction).
      static <T> ComparatorEx<T> comparingInt​(java.util.function.ToIntFunction<? super T> toKeyFn)
      Serializable variant of java.util.Comparator#comparingInt(ToIntFunction).
      static <T> ComparatorEx<T> comparingLong​(ToLongFunctionEx<? super T> toKeyFn)
      Serializable variant of java.util.Comparator#comparingLong(ToLongFunction).
      static <T> ComparatorEx<T> comparingLong​(java.util.function.ToLongFunction<? super T> toKeyFn)
      Serializable variant of java.util.Comparator#comparingLong(ToLongFunction).
      static <T extends java.lang.Comparable<? super T>>
      ComparatorEx<T>
      naturalOrder()
      Serializable variant of java.util.Comparator#naturalOrder().
      static <T> ComparatorEx<T> nullsFirst​(ComparatorEx<? super T> comparator)
      Serializable variant of java.util.Comparator#nullsFirst(Comparator).
      static <T> ComparatorEx<T> nullsFirst​(java.util.Comparator<? super T> comparator)
      Serializable variant of java.util.Comparator#nullsFirst(Comparator).
      static <T> ComparatorEx<T> nullsLast​(ComparatorEx<? super T> comparator)
      Serializable variant of java.util.Comparator#nullsLast(Comparator).
      static <T> ComparatorEx<T> nullsLast​(java.util.Comparator<? super T> comparator)
      Serializable variant of java.util.Comparator#nullsLast(Comparator).
      default ComparatorEx<T> reversed()
      Serializable variant of java.util.Comparator#reversed()
      static <T extends java.lang.Comparable<? super T>>
      ComparatorEx<T>
      reverseOrder()
      Serializable variant of java.util.Comparator#reverseOrder().
      default ComparatorEx<T> thenComparing​(ComparatorEx<? super T> other)
      Serializable variant of java.util.Comparator#thenComparing(Comparator).
      default <U extends java.lang.Comparable<? super U>>
      ComparatorEx<T>
      thenComparing​(FunctionEx<? super T,​? extends U> toKeyFn)
      Serializable variant of java.util.Comparator#thenComparing(Function).
      default <U> ComparatorEx<T> thenComparing​(FunctionEx<? super T,​? extends U> toKeyFn, ComparatorEx<? super U> keyComparator)
      Serializable variant of java.util.Comparator#thenComparing(Function, Comparator).
      default ComparatorEx<T> thenComparing​(java.util.Comparator<? super T> other)
      Serializable variant of java.util.Comparator#thenComparing(Comparator).
      default <U extends java.lang.Comparable<? super U>>
      ComparatorEx<T>
      thenComparing​(java.util.function.Function<? super T,​? extends U> toKeyFn)
      Serializable variant of java.util.Comparator#thenComparing(Function).
      default <U> ComparatorEx<T> thenComparing​(java.util.function.Function<? super T,​? extends U> toKeyFn, java.util.Comparator<? super U> keyComparator)
      Serializable variant of java.util.Comparator#thenComparing(Function, Comparator).
      default ComparatorEx<T> thenComparingDouble​(ToDoubleFunctionEx<? super T> toKeyFn)
      Serializable variant of java.util.Comparator#thenComparingDouble(ToDoubleFunction).
      default ComparatorEx<T> thenComparingDouble​(java.util.function.ToDoubleFunction<? super T> toKeyFn)
      Serializable variant of java.util.Comparator#thenComparingDouble(ToDoubleFunction).
      default ComparatorEx<T> thenComparingInt​(ToIntFunctionEx<? super T> toKeyFn)
      Serializable variant of java.util.Comparator#thenComparingInt(ToIntFunction).
      default ComparatorEx<T> thenComparingInt​(java.util.function.ToIntFunction<? super T> toKeyFn)
      Serializable variant of java.util.Comparator#thenComparingInt(ToIntFunction).
      default ComparatorEx<T> thenComparingLong​(ToLongFunctionEx<? super T> toKeyFn)
      Serializable variant of java.util.Comparator#thenComparingLong(ToLongFunction).
      default ComparatorEx<T> thenComparingLong​(java.util.function.ToLongFunction<? super T> toKeyFn)
      Serializable variant of java.util.Comparator#thenComparingLong(ToLongFunction).
      • Methods inherited from interface java.util.Comparator

        equals
    • Method Detail

      • compareEx

        int compareEx​(T o1,
                      T o2)
               throws java.lang.Exception
        Exception-declaring version of Comparator.compare(T, T).
        Throws:
        java.lang.Exception - in case of any exceptional case
      • compare

        default int compare​(T o1,
                            T o2)
        Specified by:
        compare in interface java.util.Comparator<T>
      • naturalOrder

        static <T extends java.lang.Comparable<? super T>> ComparatorEx<T> naturalOrder()
        Serializable variant of java.util.Comparator#naturalOrder().
        Type Parameters:
        T - the Comparable type of element to be compared
      • reverseOrder

        static <T extends java.lang.Comparable<? super T>> ComparatorEx<T> reverseOrder()
        Serializable variant of java.util.Comparator#reverseOrder().
        Type Parameters:
        T - the Comparable type of element to be compared
      • nullsFirst

        static <T> ComparatorEx<T> nullsFirst​(java.util.Comparator<? super T> comparator)
        Serializable variant of java.util.Comparator#nullsFirst(Comparator).
        Type Parameters:
        T - the type of the elements to be compared
      • nullsFirst

        static <T> ComparatorEx<T> nullsFirst​(ComparatorEx<? super T> comparator)
        Serializable variant of java.util.Comparator#nullsFirst(Comparator).
        Type Parameters:
        T - the type of the elements to be compared
      • nullsLast

        static <T> ComparatorEx<T> nullsLast​(java.util.Comparator<? super T> comparator)
        Serializable variant of java.util.Comparator#nullsLast(Comparator).
        Type Parameters:
        T - the type of the elements to be compared
      • nullsLast

        static <T> ComparatorEx<T> nullsLast​(ComparatorEx<? super T> comparator)
        Serializable variant of java.util.Comparator#nullsLast(Comparator).
        Type Parameters:
        T - the type of the elements to be compared
      • comparing

        static <T,​U> ComparatorEx<T> comparing​(java.util.function.Function<? super T,​? extends U> toKeyFn,
                                                     java.util.Comparator<? super U> keyComparator)
        Serializable variant of java.util.Comparator#comparing(Function, Comparator).
        Type Parameters:
        T - the type of element to be compared
        U - the type of the sort key
      • comparing

        static <T,​U> ComparatorEx<T> comparing​(FunctionEx<? super T,​? extends U> toKeyFn,
                                                     ComparatorEx<? super U> keyComparator)
        Serializable variant of java.util.Comparator#comparing(Function, Comparator).
        Type Parameters:
        T - the type of element to be compared
        U - the type of the sort key
      • comparing

        static <T,​U extends java.lang.Comparable<? super U>> ComparatorEx<T> comparing​(java.util.function.Function<? super T,​? extends U> toKeyFn)
        Serializable variant of java.util.Comparator#comparing(Function).
        Type Parameters:
        T - the type of element to be compared
        U - the type of the Comparable sort key
      • comparing

        static <T,​U extends java.lang.Comparable<? super U>> ComparatorEx<T> comparing​(FunctionEx<? super T,​? extends U> toKeyFn)
        Serializable variant of java.util.Comparator#comparing(Function).
        Type Parameters:
        T - the type of element to be compared
        U - the type of the Comparable sort key
      • comparingInt

        static <T> ComparatorEx<T> comparingInt​(java.util.function.ToIntFunction<? super T> toKeyFn)
        Serializable variant of java.util.Comparator#comparingInt(ToIntFunction).
        Type Parameters:
        T - the type of element to be compared
      • comparingInt

        static <T> ComparatorEx<T> comparingInt​(ToIntFunctionEx<? super T> toKeyFn)
        Serializable variant of java.util.Comparator#comparingInt(ToIntFunction).
        Type Parameters:
        T - the type of element to be compared
      • comparingLong

        static <T> ComparatorEx<T> comparingLong​(java.util.function.ToLongFunction<? super T> toKeyFn)
        Serializable variant of java.util.Comparator#comparingLong(ToLongFunction).
        Type Parameters:
        T - the type of element to be compared
      • comparingLong

        static <T> ComparatorEx<T> comparingLong​(ToLongFunctionEx<? super T> toKeyFn)
        Serializable variant of java.util.Comparator#comparingLong(ToLongFunction).
        Type Parameters:
        T - the type of element to be compared
      • comparingDouble

        static <T> ComparatorEx<T> comparingDouble​(java.util.function.ToDoubleFunction<? super T> toKeyFn)
        Serializable variant of java.util.Comparator#comparingDouble(ToDoubleFunction).
        Type Parameters:
        T - the type of element to be compared
      • comparingDouble

        static <T> ComparatorEx<T> comparingDouble​(ToDoubleFunctionEx<? super T> toKeyFn)
        Serializable variant of java.util.Comparator#comparingDouble(ToDoubleFunction).
        Type Parameters:
        T - the type of element to be compared
      • thenComparing

        default ComparatorEx<T> thenComparing​(java.util.Comparator<? super T> other)
        Serializable variant of java.util.Comparator#thenComparing(Comparator).
        Specified by:
        thenComparing in interface java.util.Comparator<T>
      • thenComparing

        default ComparatorEx<T> thenComparing​(ComparatorEx<? super T> other)
        Serializable variant of java.util.Comparator#thenComparing(Comparator).
      • thenComparing

        default <U> ComparatorEx<T> thenComparing​(java.util.function.Function<? super T,​? extends U> toKeyFn,
                                                  java.util.Comparator<? super U> keyComparator)
        Serializable variant of java.util.Comparator#thenComparing(Function, Comparator).
        Specified by:
        thenComparing in interface java.util.Comparator<T>
        Type Parameters:
        U - the type of the sort key
      • thenComparing

        default <U> ComparatorEx<T> thenComparing​(FunctionEx<? super T,​? extends U> toKeyFn,
                                                  ComparatorEx<? super U> keyComparator)
        Serializable variant of java.util.Comparator#thenComparing(Function, Comparator).
        Type Parameters:
        U - the type of the sort key
      • thenComparing

        default <U extends java.lang.Comparable<? super U>> ComparatorEx<T> thenComparing​(java.util.function.Function<? super T,​? extends U> toKeyFn)
        Serializable variant of java.util.Comparator#thenComparing(Function).
        Specified by:
        thenComparing in interface java.util.Comparator<T>
        Type Parameters:
        U - the type of the Comparable sort key
      • thenComparing

        default <U extends java.lang.Comparable<? super U>> ComparatorEx<T> thenComparing​(FunctionEx<? super T,​? extends U> toKeyFn)
        Serializable variant of java.util.Comparator#thenComparing(Function).
        Type Parameters:
        U - the type of the Comparable sort key
      • thenComparingInt

        default ComparatorEx<T> thenComparingInt​(java.util.function.ToIntFunction<? super T> toKeyFn)
        Serializable variant of java.util.Comparator#thenComparingInt(ToIntFunction).
        Specified by:
        thenComparingInt in interface java.util.Comparator<T>
      • thenComparingInt

        default ComparatorEx<T> thenComparingInt​(ToIntFunctionEx<? super T> toKeyFn)
        Serializable variant of java.util.Comparator#thenComparingInt(ToIntFunction).
      • thenComparingLong

        default ComparatorEx<T> thenComparingLong​(java.util.function.ToLongFunction<? super T> toKeyFn)
        Serializable variant of java.util.Comparator#thenComparingLong(ToLongFunction).
        Specified by:
        thenComparingLong in interface java.util.Comparator<T>
      • thenComparingLong

        default ComparatorEx<T> thenComparingLong​(ToLongFunctionEx<? super T> toKeyFn)
        Serializable variant of java.util.Comparator#thenComparingLong(ToLongFunction).
      • thenComparingDouble

        default ComparatorEx<T> thenComparingDouble​(java.util.function.ToDoubleFunction<? super T> toKeyFn)
        Serializable variant of java.util.Comparator#thenComparingDouble(ToDoubleFunction).
        Specified by:
        thenComparingDouble in interface java.util.Comparator<T>
      • thenComparingDouble

        default ComparatorEx<T> thenComparingDouble​(ToDoubleFunctionEx<? super T> toKeyFn)
        Serializable variant of java.util.Comparator#thenComparingDouble(ToDoubleFunction).
      • reversed

        default ComparatorEx<T> reversed()
        Serializable variant of java.util.Comparator#reversed()
        Specified by:
        reversed in interface java.util.Comparator<T>