Type Parameters:
T - the type of objects that may be compared by this comparator
All Known Implementing Classes:
Collator, RuleBasedCollator
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

  • Method Summary

    int

    compare(T o1, T o2)

    Compares its two arguments for order.

    comparing(Function<? super T, ? extends U> keyExtractor)

    Accepts a function that extracts a Comparable sort key from a type T, and returns a Comparator<T> that compares by that sort key.

    comparing(Function<? super T, ? extends U> keyExtractor, Comparator<? super U> keyComparator)

    Accepts a function that extracts a sort key from a type T, and returns a Comparator<T> that compares by that sort key using the specified Comparator.

    Accepts a function that extracts a double sort key from a type T, and returns a Comparator<T> that compares by that sort key.

    Accepts a function that extracts an int sort key from a type T, and returns a Comparator<T> that compares by that sort key.

    Accepts a function that extracts a long sort key from a type T, and returns a Comparator<T> that compares by that sort key.

    boolean

    Indicates whether some other object is "equal to" this comparator.

    default <U extends T>
    U

    max(U o1, U o2)

    Returns the greater of two values according to this comparator.

    default <U extends T>
    U

    min(U o1, U o2)

    Returns the smaller of two values according to this comparator.

    Returns a comparator that compares Comparable objects in natural order.

    Returns a null-friendly comparator that considers null to be less than non-null.

    Returns a null-friendly comparator that considers null to be greater than non-null.

    reversed()

    Returns a comparator that imposes the reverse ordering of this comparator.

    Returns a comparator that imposes the reverse of the natural ordering.

    Returns a lexicographic-order comparator with another comparator.

    thenComparing(Function<? super T, ? extends U> keyExtractor)

    Returns a lexicographic-order comparator with a function that extracts a Comparable sort key.

    thenComparing(Function<? super T, ? extends U> keyExtractor, Comparator<? super U> keyComparator)

    Returns a lexicographic-order comparator with a function that extracts a key to be compared with the given Comparator.

    Returns a lexicographic-order comparator with a function that extracts a double sort key.

    Returns a lexicographic-order comparator with a function that extracts an int sort key.

    Returns a lexicographic-order comparator with a function that extracts a long sort key.

  • Method Details

    • compare

    • equals

    • reversed

    • max

    • min

    • thenComparing

    • thenComparing

    • thenComparing

    • thenComparingInt

    • thenComparingLong

    • thenComparingDouble

    • reverseOrder

    • naturalOrder

    • nullsFirst

    • nullsLast

    • comparing

    • comparing

    • comparingInt

    • comparingLong

    • comparingDouble