| java.lang.Object | |
| ↳ | org.springframework.util.comparator.NullSafeComparator<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.
| Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| NULLS_HIGH | A shared default instance of this comparator, treating nulls higher than non-null objects. | ||||||||||
| NULLS_LOW | A shared default instance of this comparator, treating nulls lower than non-null objects. | ||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Create a NullSafeComparator that sorts
null based on the
provided flag, decorating the given Comparator. | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.util.Comparator
| |||||||||||
A shared default instance of this comparator, treating nulls higher than non-null objects.
A shared default instance of this comparator, treating nulls lower than non-null objects.
Create a NullSafeComparator that sorts null based on the
provided flag, decorating the given Comparator.
When comparing two non-null objects, the specified Comparator will be used. The given underlying Comparator must be able to handle the elements that this Comparator will be applied to.
| comparator | the comparator to use when comparing two non-null objects |
|---|---|
| nullsLow | whether to treat nulls lower or higher than non-null objects |