Пример #1
0
 /**
  * @param name the name of the method
  * @param parameterTypes the types of the parameters of the method
  * @return the public method that matches the name and parameter types of this type or one of its
  *     super interfaces.
  * @throws NoSuchMethodException
  */
 public Method getMethod(String name, Class... parameterTypes) throws NoSuchMethodException {
   Type t = this;
   while (t != null) {
     Method[] declMethods = t.getDeclaredMethods();
     if (declMethods != null) {
       for (Method m : declMethods) {
         if (m.isPublic() && m.match(name, parameterTypes)) return m;
       }
     }
     t = t.getSuperclass();
   }
   throw new NoSuchMethodException();
 }
Пример #2
0
 /**
  * s * @return an array containing all public methods of this class and its super classes. See
  * {@link Class#getMethods()}.
  */
 public Method[] getMethods() {
   if (allMethods == null) {
     ArrayList<Method> allMethodsList = new ArrayList<Method>();
     Type t = this;
     while (t != null) {
       for (Method m : t.methods) {
         if (m.isPublic()) allMethodsList.add(m);
       }
       t = t.getSuperclass();
     }
     allMethods = allMethodsList.toArray(new Method[allMethodsList.size()]);
   }
   return allMethods;
 }
Пример #3
0
 /**
  * s * @return an array containing all public methods of this class and its super classes. See
  * {@link Class#getMethods()}.
  */
 public Method[] getMethods() {
   ArrayList<Method> allMethods = new ArrayList<Method>();
   Type t = this;
   while (t != null) {
     Method[] declMethods = t.getDeclaredMethods();
     if (declMethods != null) {
       for (Method m : declMethods) {
         if (m.isPublic()) allMethods.add(m);
       }
     }
     t = t.getSuperclass();
   }
   return allMethods.toArray(new Method[allMethods.size()]);
 }