public class ComparatorComparableNullAware<DATATYPE extends Comparable<? super DATATYPE>> extends AbstractComparator<DATATYPE>
Comparator for Comparable
objects. In comparison to ComparatorComparable this class can handle
null values.| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEFAULT_NULL_VALUES_COME_FIRST
Default value wether
null values come first or last |
| Constructor and Description |
|---|
ComparatorComparableNullAware()
Comparator with default sort order.
|
ComparatorComparableNullAware(Comparator<? super DATATYPE> aNestedComparator)
Comparator with default sort order and a nested comparator.
|
ComparatorComparableNullAware(ESortOrder eSortOrder)
Constructor with sort order.
|
ComparatorComparableNullAware(ESortOrder eSortOrder,
Comparator<? super DATATYPE> aNestedComparator)
Comparator with sort order and a nested comparator.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
isNullValuesComeFirst() |
protected int |
mainCompare(DATATYPE aElement1,
DATATYPE aElement2) |
ComparatorComparableNullAware<DATATYPE> |
setNullValuesComeFirst(boolean bNullValuesComeFirst) |
compare, getSortOrder, setSortOrderclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitequalspublic static final boolean DEFAULT_NULL_VALUES_COME_FIRST
null values come first or lastpublic ComparatorComparableNullAware()
public ComparatorComparableNullAware(@Nonnull ESortOrder eSortOrder)
eSortOrder - The sort order to use. May not be null.public ComparatorComparableNullAware(@Nullable Comparator<? super DATATYPE> aNestedComparator)
aNestedComparator - The nested comparator to be invoked, when the main comparison
resulted in 0.public ComparatorComparableNullAware(@Nonnull ESortOrder eSortOrder, @Nullable Comparator<? super DATATYPE> aNestedComparator)
eSortOrder - The sort order to use. May not be null.aNestedComparator - The nested comparator to be invoked, when the main comparison
resulted in 0.public final boolean isNullValuesComeFirst()
@Nonnull public final ComparatorComparableNullAware<DATATYPE> setNullValuesComeFirst(boolean bNullValuesComeFirst)
protected final int mainCompare(@Nullable DATATYPE aElement1, @Nullable DATATYPE aElement2)
mainCompare in class AbstractComparator<DATATYPE extends Comparable<? super DATATYPE>>aElement1 - First element to compare. No information on the null
status.aElement2 - Second element to compare. No information on the null
status.Copyright © 2006–2014 phloc systems. All rights reserved.