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 to compare null
and non-null values. Before the decorated Comparator will be executed null check will be
executed. Over the flag 'nullIsGreaterThan' can be controlled whether null object values are
greater or less than non-null object values.| 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> Comparator<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> Comparator<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 decoratedComparator 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.