code: public static <T extends Comparable<T>> int compare(T left, T right) {
          int result;
          if (left == null) {
              if (right == null) {
                  result = 0;
              } else {
                  result = -1;
              }
          } else {
              if (right == null) {
                  result = 1;
              } else {
                  result = left.compareTo(right);
              }
          }
          return result;
      }
docs: Compares the two given objects, handling <code>null</code> values predictably. A <code>null</code> value is
  compared smaller than a non-<code>null</code> value. See {@link Comparable#compareTo(Object)} for
  the definition of the return value.
  
  @param left The left object
  @param right The right object
  @param <T> The type of both objects, extends {@link Comparable}
  @return an indication of whether <code>left</code> is smaller than, greater than or equal to <code>right</code>