Class NullSafeComparator<T>
java.lang.Object
org.springframework.util.comparator.NullSafeComparator<T>
- Type Parameters:
- T- the type of objects that may be compared by this comparator
- All Implemented Interfaces:
- Comparator<T>
Deprecated.
A Comparator that will safely compare nulls to be lower or higher than
 other objects. Can decorate a given Comparator or work on Comparables.
- Since:
- 1.2.2
- Author:
- Keith Donald, Juergen Hoeller
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final NullSafeComparatorDeprecated.A shared default instance of this comparator, treating nulls higher than non-null objects.static final NullSafeComparatorDeprecated.A shared default instance of this comparator, treating nulls lower than non-null objects.
- 
Constructor SummaryConstructorsConstructorDescriptionNullSafeComparator(Comparator<T> comparator, boolean nullsLow) Deprecated.Create a NullSafeComparator that sortsnullbased on the provided flag, decorating the given Comparator.
- 
Method SummaryMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Comparatorreversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
- 
Field Details- 
NULLS_LOWDeprecated.A shared default instance of this comparator, treating nulls lower than non-null objects.- See Also:
 
- 
NULLS_HIGHDeprecated.A shared default instance of this comparator, treating nulls higher than non-null objects.- See Also:
 
 
- 
- 
Constructor Details- 
NullSafeComparatorDeprecated.Create a NullSafeComparator that sortsnullbased 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. - Parameters:
- comparator- the comparator to use when comparing two non-null objects
- nullsLow- whether to treat nulls lower or higher than non-null objects
 
 
- 
- 
Method Details- 
compareDeprecated.- Specified by:
- comparein interface- Comparator<T>
 
- 
equalsDeprecated.- Specified by:
- equalsin interface- Comparator<T>
- Overrides:
- equalsin class- Object
 
- 
hashCodepublic int hashCode()Deprecated.
- 
toStringDeprecated.
 
- 
Comparator.nullsLast(java.util.Comparator<? super T>)andComparator.nullsFirst(java.util.Comparator<? super T>)