code: public static <T extends Comparable<T>> int checkCompare(T a, T b) {
          return a == null ?
                  b == null ? 0 : -1 :
                      b == null ? 1 : a.compareTo(b);
        }
docs: Convenience utility. Does null checks on objects, then calls compare.