T - the generic type of the Comparator object that will be decoratedpublic class NullCheckComparator<T> extends Object implements Comparator<T>, Serializable
NullCheckComparator decorates another Comparator object. Before the
decorated Comparator will be executed null check will be executed.| Constructor and Description |
|---|
NullCheckComparator(Comparator<T> decoratedComparator)
Instantiates a
NullCheckComparator from the given Comparator object. |
NullCheckComparator(Comparator<T> decoratedComparator,
boolean nullIsGreaterThan)
Instantiates a
NullCheckComparator from the given Comparator object and the
given flag. |
| Modifier and Type | Method and Description |
|---|---|
int |
compare(T object,
T compareWithObject) |
static <T> NullCheckComparator<T> |
of(Comparator<T> decoratedComparator)
Factory method to create a new
NullCheckComparator object from the given
Comparator object. |
static <T> NullCheckComparator<T> |
of(Comparator<T> decoratedComparator,
boolean nullIsGreaterThan)
Factory method to create a new
NullCheckComparator object from the given
Comparator object. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcomparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongpublic NullCheckComparator(Comparator<T> decoratedComparator)
NullCheckComparator from the given Comparator object. The flag
nullIsGreaterThan is set to false so null objects are smaller then non null objects.decoratedComparator - the Comparator object that will be decoratedpublic NullCheckComparator(Comparator<T> decoratedComparator, boolean nullIsGreaterThan)
NullCheckComparator from the given Comparator object and the
given flag.decoratedComparator - the Comparator object that will be decoratednullIsGreaterThan - the flag that specifies if null objects is greater than non null objects.public static <T> NullCheckComparator<T> of(Comparator<T> decoratedComparator)
NullCheckComparator object from the given
Comparator object.T - the generic type of the Comparator object that will be decorateddecoratedComparator - the Comparator object that will be decoratedNullCheckComparator objectpublic static <T> NullCheckComparator<T> of(Comparator<T> decoratedComparator, boolean nullIsGreaterThan)
NullCheckComparator object from the given
Comparator object.T - the generic type of the Comparator object that will be decorateddecoratedComparator - the Comparator object that will be decoratednullIsGreaterThan - the flag that specifies if null objects is greater than non null objects.NullCheckComparator objectpublic int compare(T object, T compareWithObject)
compare in interface Comparator<T>Copyright © 2015–2017 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.