Java Utililty Methods Comparable

List of utility methods to do Comparable

Description

The list of methods to do Comparable are organized into topic(s).

Method

intcompare(Comparable left, Comparable right)
compare
if (left == null && right == null)
    return 0;
else if (left == null)
    return -1;
else if (right == null)
    return 1;
else
    return left.compareTo(right);
...
intcompare(Comparable obj1, T obj2)
compare
if (obj1 == null) {
    if (obj2 == null) {
        return 0;
    } else {
        return 1;
} else {
    return obj1.compareTo(obj2);
...
intcompare(final Comparable left, final Comparable right)
Compares to comparable objects -- defending against null.
if (left == null && right == null) {
    return 0;
} else if (left == null) {
    return -1;
} else if (right == null) {
    return 1;
} else {
    return left.compareTo(right);
...