Ejemplo n.º 1
0
 private static void findCallbacks(Class<?> type, Map<String, Method> result) {
   ArrayList<Class<?>> classes = new ArrayList<Class<?>>();
   if (!type.isInterface()) {
     // No need to search interfaces since interfaces cannot have
     // static methods and callbacks must be static.
     classes.add(type);
   } else {
     Class<?> objCProxy = allObjCProxyClasses.get(type.getName());
     if (objCProxy != null) {
       classes.add(objCProxy);
     }
   }
   try {
     classes.add(Class.forName(type.getName() + "$Callbacks", true, type.getClassLoader()));
   } catch (ClassNotFoundException ignored) {
   }
   for (Class<?> c : classes) {
     for (Method m : c.getDeclaredMethods()) {
       if (m.getAnnotation(Callback.class) != null) {
         BindSelector bindSelector = m.getAnnotation(BindSelector.class);
         if (bindSelector != null) {
           if (!result.containsKey(bindSelector.value())) {
             result.put(bindSelector.value(), m);
           }
         }
       }
     }
   }
 }
Ejemplo n.º 2
0
 private static void findNotImplemented(Class<?> type, Map<String, Method> result) {
   Class<?> superclass = type.getSuperclass();
   if (superclass != null) {
     findNotImplemented(superclass, result);
   }
   for (Method m : type.getDeclaredMethods()) {
     NotImplemented ni = m.getAnnotation(NotImplemented.class);
     if (ni != null) {
       result.put(ni.value(), m);
     } else {
       BindSelector bs = m.getAnnotation(BindSelector.class);
       if (bs != null) {
         result.remove(bs.value());
       } else {
         String mName = m.getName();
         Class<?>[] mParamTypes = m.getParameterTypes();
         for (Iterator<Entry<String, Method>> it = result.entrySet().iterator(); it.hasNext(); ) {
           Entry<String, Method> entry = it.next();
           Method m2 = entry.getValue();
           if (m2.getName().equals(mName) && Arrays.equals(m2.getParameterTypes(), mParamTypes)) {
             it.remove();
           }
         }
       }
     }
   }
 }