Java Reflection Method Get from Object getMethod(Object pojo, String methodName, Class[] params)

Here you can find the source of getMethod(Object pojo, String methodName, Class[] params)

Description

get Method

License

Open Source License

Parameter

Parameter Description
pojo a parameter
methodName a parameter
params a parameter

Declaration

public static Method getMethod(Object pojo, String methodName, Class<?>[] params) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.lang.reflect.Method;

public class Main {
    /**/*from   ww w.  j ava2s. c  o  m*/
     * 
     * @param pojo
     * @param methodName
     * @param params
     * @return
     */
    public static Method getMethod(Object pojo, String methodName, Class<?>[] params) {
        Method method = null;

        Class<?> cClass = pojo.getClass();
        while (cClass != null && method == null) {
            try {
                method = cClass.getDeclaredMethod(methodName, params);
            } catch (NoSuchMethodException nsf) {
                cClass = cClass.getSuperclass();
            }
        }

        return method;
    }
}

Related

  1. getMethod(Object obj, String methodName, Class... parameterTypes)
  2. getMethod(Object obj, String name, Class... types)
  3. getMethod(Object object, String methodName, Class... arguments)
  4. getMethod(Object object, String name, Object... params)
  5. getMethod(Object oo, String mname)
  6. getMethod(Object target, String methodName)
  7. getMethod(Object target, String methodName, Class... parameterTypes)
  8. getMethod(Object target, String signature)
  9. getMethod(String methodName, Object instance)