T
- The type of the Objects to compare.@Status(stage=PRODUCTION, unitTests=PARTIAL) @Review(by="Kees Schotanus", at="2009-09-28") public final class CComparator<T extends Comparable<? super T>> extends Object implements Comparator<T>, Serializable
Comparable
.
Modifier and Type | Class and Description |
---|---|
static class |
CComparator.OrderNulls
Determines whether Null values are ordered high or low.
|
Constructor and Description |
---|
CComparator()
Constructs this Comparator that compares two objects of type <T>.
|
CComparator(Order order)
Constructs this Comparator that compares two objects of type <T>.
|
CComparator(Order order,
CComparator.OrderNulls orderNulls)
Constructs this Comparator that compares two objects of type <T>.
|
Modifier and Type | Method and Description |
---|---|
int |
compare(T left,
T right)
Utility method to compare two objects of type <T>.
|
static <T extends Comparable<? super T>> |
compareAllowingNulls(T left,
T right)
Utility method to compare two objects.
|
static <T extends Comparable<? super T>> |
compareAllowingNulls(T left,
T right,
Order order)
Utility method to compare two objects.
|
static <T extends Comparable<? super T>> |
compareAllowingNulls(T left,
T right,
Order order,
CComparator.OrderNulls orderNulls)
Utility method to compare two objects.
|
static int |
compareStringsIgnoringCase(String stringLeft,
String stringRight)
Utility method to compare two Strings, ignoring case, while allowing for null Strings.
|
Order |
getOrdering()
Gets the order of non-null values.
|
CComparator.OrderNulls |
getOrderNulls()
Gets the order of null values.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
public CComparator()
public CComparator(Order order)
order
- Determines whether objects are ordered ascending or descending.NullPointerException
- When the supplied order is null.public CComparator(Order order, CComparator.OrderNulls orderNulls)
order
- Determines whether objects are ordered ascending or descending.orderNulls
- Determines whether null values are ordered high or low.NullPointerException
- When either the supplied order or orderNulls is null.public Order getOrdering()
public CComparator.OrderNulls getOrderNulls()
public int compare(T left, T right)
compare
in interface Comparator<T extends Comparable<? super T>>
left
- The Object on the left.right
- The Object on the right.public static <T extends Comparable<? super T>> int compareAllowingNulls(T left, T right)
T
- Type of the objects to compare.left
- The Object on the left.right
- The Object on the right.public static <T extends Comparable<? super T>> int compareAllowingNulls(T left, T right, Order order)
T
- Type of the objects to compare.left
- The Object on the left.right
- The Object on the right.order
- Determines whether non-null values are ordered ascending or descending.
public static <T extends Comparable<? super T>> int compareAllowingNulls(T left, T right, Order order, CComparator.OrderNulls orderNulls)
T
- Type of the object to compare to this one.left
- The Object on the left.right
- The Object on the right.order
- Determines whether non-null values are ordered ascending or descending.
The order should not be null but for performance reasons no explicit check is performed.orderNulls
- Determines whether null values are ordered after non-null values or before non-null values.
public static int compareStringsIgnoringCase(String stringLeft, String stringRight)
stringLeft
- The String on the left.stringRight
- The String on the right.Copyright © 2008–2018. All rights reserved.