Package org.springframework.util.comparator

# Class Comparators

java.lang.Object
org.springframework.util.comparator.Comparators

public abstract class Comparators extends Object
Convenient entry point with generically typed factory methods for common Spring `Comparator` variants.

Since:
  5.0
Author:
  Juergen Hoeller

## Constructor Summary

Constructors
Constructor
Description
`Comparators()`

## Method Summary

Modifier and Type
Method
Description
`static <T> Comparator<T>`
`comparable()`
Return a `Comparable` adapter.
`static <T> Comparator<T>`
`nullsHigh()`
Return a `Comparable` adapter which accepts null values and sorts them higher than non-null values.
`static <T> Comparator<T>`
`nullsHigh(Comparator<T> comparator)`
Return a decorator for the given comparator which accepts null values and sorts them higher than non-null values.
`static <T> Comparator<T>`
`nullsLow()`
Return a `Comparable` adapter which accepts null values and sorts them lower than non-null values.
`static <T> Comparator<T>`
`nullsLow(Comparator<T> comparator)`
Return a decorator for the given comparator which accepts null values and sorts them lower than non-null values.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### Comparators

public Comparators()

## Method Details

### comparable

public static <T> Comparator<T> comparable()
Return a `Comparable` adapter.

See Also:
  - `Comparator.naturalOrder()`

### nullsLow

public static <T> Comparator<T> nullsLow()
Return a `Comparable` adapter which accepts null values and sorts them lower than non-null values.

See Also:
  - `Comparator.nullsFirst(Comparator)`

### nullsLow

public static <T> Comparator<T> nullsLow(Comparator<T> comparator)
Return a decorator for the given comparator which accepts null values and sorts them lower than non-null values.

See Also:
  - `Comparator.nullsFirst(Comparator)`

### nullsHigh

public static <T> Comparator<T> nullsHigh()
Return a `Comparable` adapter which accepts null values and sorts them higher than non-null values.

See Also:
  - `Comparator.nullsLast(Comparator)`

### nullsHigh

public static <T> Comparator<T> nullsHigh(Comparator<T> comparator)
Return a decorator for the given comparator which accepts null values and sorts them higher than non-null values.

See Also:
  - `Comparator.nullsLast(Comparator)`