code: public static float getTypeDifferenceWeight(Class<?> srcClass, Class<?> destClass) {
          if (srcClass == null) {
              return Float.MAX_VALUE;
          }
  
          if (destClass != null) {
              if (srcClass.isArray() && destClass.isArray()) {
                  srcClass = srcClass.getComponentType();
                  destClass = destClass.getComponentType();
              }
              if ((destClass.isPrimitive()
                      && srcClass.equals(TypeUtils.getPrimitiveWrapper(destClass)))
                      || (srcClass.isPrimitive()
                      && destClass.equals(TypeUtils.getPrimitiveWrapper(srcClass)))) {
                  return 0.1f;
              }
          }
  
          float weight = 0.0f;
          while (destClass != null) {
              if (destClass.equals(srcClass)) {
                  if (destClass.isInterface()) {
                      // slight penalty for interface match.
                      // we still want an exact match to override an interface match, but
                      // an interface match should override anything where we have to get a
                      // superclass.
                      weight += 0.25f;
                  }
                  break;
              }
              weight++;
              destClass = destClass.getSuperclass();
          }
  
          /*
           * If the destination class is null, we've travelled all the way up to
           * an Object match. We'll penalize this by adding 1.5 to the cost.
           */
          if (destClass == null) {
              weight += 1.5f;
          }
          return weight;
      }
docs: Gets the number of steps required needed to turn the source class into the
  destination class. This represents the number of steps in the object hierarchy
  graph.
  
  @param srcClass the source class
  @param destClass the destination class
  @return the cost of transforming an object