예제 #1
0
파일: EnvUtil.java 프로젝트: noter/errai
 private static void fillInInterfacesAndSuperTypes(
     final Set<MetaClass> set, final MetaClass type) {
   for (final MetaClass iface : type.getInterfaces()) {
     set.add(iface);
     fillInInterfacesAndSuperTypes(set, iface);
   }
   if (type.getSuperClass() != null) {
     fillInInterfacesAndSuperTypes(set, type.getSuperClass());
   }
 }
예제 #2
0
  public static MetaMethod findCaseInsensitiveMatch(
      final MetaClass retType, final MetaClass clazz, final String name, final MetaClass... parms) {
    MetaClass c = clazz;

    do {
      Outer:
      for (final MetaMethod method : c.getDeclaredMethods()) {
        if (name.equalsIgnoreCase(method.getName())) {
          if (parms.length != method.getParameters().length) continue;

          final MetaParameter[] mps = method.getParameters();
          for (int i = 0; i < parms.length; i++) {
            if (!parms[i]
                .getFullyQualifiedName()
                .equals(mps[i].getType().getFullyQualifiedName())) {
              continue Outer;
            }
          }

          if (retType != null
              && !retType
                  .getFullyQualifiedName()
                  .equals(method.getReturnType().getFullyQualifiedName())) {
            continue;
          }

          return method;
        }
      }
    } while ((c = c.getSuperClass()) != null);

    return null;
  }
예제 #3
0
 private static List<MetaField> getAllFields(MetaClass c) {
   ArrayList<MetaField> fields = new ArrayList<MetaField>();
   for (; c != null; c = c.getSuperClass()) {
     fields.addAll(Arrays.asList(c.getDeclaredFields()));
   }
   return fields;
 }
예제 #4
0
 public static int scoreInterface(final MetaClass parm, final MetaClass arg) {
   if (parm.isInterface()) {
     final MetaClass[] iface = arg.getInterfaces();
     if (iface != null) {
       for (final MetaClass c : iface) {
         if (c == parm) return 1;
         else if (parm.isAssignableFrom(c)) return scoreInterface(parm, arg.getSuperClass());
       }
     }
   }
   return 0;
 }