示例#1
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();
           }
         }
       }
     }
   }
 }
示例#2
0
 private static Map<String, Method> getCallbacks(Class<?> type) {
   Map<String, Method> notImplemented = new HashMap<String, Method>();
   findNotImplemented(type, notImplemented);
   Map<String, Method> callbacks = new HashMap<String, Method>();
   findCallbacksOnClasses(type, callbacks);
   findCallbacksOnInterfaces(type, callbacks);
   // Remove callbacks which have a corresponding @NotImplemented method
   callbacks.keySet().removeAll(notImplemented.keySet());
   return callbacks;
 }