code: private int typeDepth(Class<?> match, Class<?> actual)
    {
      if (actual == null) {
        return Integer.MAX_VALUE / 2;
      }
      
      if (match.equals(Object.class)) {
        return Integer.MAX_VALUE / 4;
      }
      
      if (match.equals(actual)) {
        return 0;
      }
      
      int cost = 1 + typeDepth(match, actual.getSuperclass());
      
      for (Class<?> iface : actual.getInterfaces()) {
        cost = Math.min(cost, 1 + typeDepth(match, iface));
      }
      
      return cost;
    }
docs: count of how closely the source matches the target.