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(since="6.1") public class NullSafeComparator<T> extends Object implements 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.
Since:
1.2.2
Author:
Keith Donald, Juergen Hoeller
See Also:
  • Field Details

  • Constructor Details

    • NullSafeComparator

      public NullSafeComparator(Comparator<T> comparator, boolean nullsLow)
      Deprecated.
      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.

      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