code: @SuppressWarnings({"rawtypes","unchecked"}) // for cast to Comparable
      static int compareComparables(Class<?> kc, Object k, Object x) {
          return (x == null || x.getClass() != kc ? 0 :
                  ((Comparable)k).compareTo(x));
      }
docs: Returns k.compareTo(x) if x matches kc (k's screened comparable
  class), else 0.