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 SpringComparator
variants.- Since:
- 5.0
- Author:
- Juergen Hoeller
Constructor Summary
Constructors Constructor Description Comparators()
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Comparator<T>
comparable()
Return aComparable
adapter.static <T> Comparator<T>
nullsHigh()
Return aComparable
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 aComparable
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.
Constructor Detail
Comparators
public Comparators()
Method Detail
comparable
public static <T> Comparator<T> comparable()
Return aComparable
adapter.- See Also:
ComparableComparator.INSTANCE
nullsLow
public static <T> Comparator<T> nullsLow()
Return aComparable
adapter which accepts null values and sorts them lower than non-null values.- See Also:
NullSafeComparator.NULLS_LOW
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:
NullSafeComparator(boolean)
nullsHigh
public static <T> Comparator<T> nullsHigh()
Return aComparable
adapter which accepts null values and sorts them higher than non-null values.- See Also:
NullSafeComparator.NULLS_HIGH
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:
NullSafeComparator(boolean)