static boolean derivesFrom(Class<?> c, String className) {
   while (c != null) {
     if (c.getName().equals(className)) return true;
     c = c.getSuperclass();
   }
   return false;
 }
    public boolean matchesEnclosingType(Method method) {
      TypeRef et = getEnclosingType();
      if (et == null) {
        return true;
      }

      Annotations annotations = annotations(method);
      Class dc = method.getDeclaringClass();
      do {
        if (et.matches(dc, annotations)) {
          return true;
        }

        dc = dc.getSuperclass();
      } while (dc != null && dc != Object.class);

      return false;
    }