T - the type of objects that may be compared by this comparatorpublic class NullSafeComparator<T> extends Object implements Comparator<T>
Comparable| Modifier and Type | Field and Description | 
|---|---|
| static NullSafeComparator | NULLS_HIGHA shared default instance of this comparator, treating nulls higher
 than non-null objects. | 
| static NullSafeComparator | NULLS_LOWA shared default instance of this comparator, treating nulls lower
 than non-null objects. | 
| Constructor and Description | 
|---|
| NullSafeComparator(Comparator<T> comparator,
                  boolean nullsLow)Create a NullSafeComparator that sorts  nullbased on the
 provided flag, decorating the given Comparator. | 
| Modifier and Type | Method and Description | 
|---|---|
| int | compare(T o1,
       T o2) | 
| boolean | equals(Object other) | 
| int | hashCode() | 
| String | toString() | 
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcomparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongpublic static final NullSafeComparator NULLS_LOW
Comparators.nullsLow()public static final NullSafeComparator NULLS_HIGH
Comparators.nullsHigh()public NullSafeComparator(Comparator<T> comparator, boolean nullsLow)
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 objectsnullsLow - whether to treat nulls lower or higher than non-null objects