spring-framework / org.springframework.util.comparator

Package org.springframework.util.comparator

Types

BooleanComparator

open class BooleanComparator : Comparator<Boolean>, Serializable

A Comparator for Boolean objects that can sort either true or false first.

ComparableComparator

open class ComparableComparator<T : Comparable<T>> : Comparator<T>

Comparator that adapts Comparables to the Comparator interface. Mainly for internal use in other Comparators, when supposed to work on Comparables.

CompoundComparator

open class CompoundComparator<T : Any> : Comparator<T>, Serializable

A comparator that chains a sequence of one or more Comparators.

A compound comparator calls each Comparator in sequence until a single Comparator returns a non-zero result, or the comparators are exhausted and zero is returned.

This facilitates in-memory sorting similar to multi-column sorting in SQL. The order of any single Comparator in the list can also be reversed.

NullSafeComparator

open class NullSafeComparator<T : Any> : Comparator<T>

A Comparator that will safely compare nulls to be lower or higher than other objects. Can decorate a given Comparator or work on Comparables.