Java Reflection Method Get from Object getMethod(String methodName, Object instance)

Here you can find the source of getMethod(String methodName, Object instance)

Description

get Method Name

License

Open Source License

Parameter

Parameter Description
methodName a parameter
instance a parameter

Return

Method

Declaration

public static Method getMethod(String methodName, Object instance) 

Method Source Code


//package com.java2s;
import java.lang.reflect.Method;

public class Main {
    /**/*from w  w w  . j  a v a 2s .  com*/
     * get Method Name
     * 
     * @param methodName
     * @param instance
     * 
     * @return Method
     */
    public static Method getMethod(String methodName, Object instance) {
        Method[] methods = instance.getClass().getMethods();
        for (Method m : methods) {
            if (m.getName().equalsIgnoreCase(methodName)) {
                return m;
            }
        }
        return null;
    }
}

Related

  1. getMethod(Object oo, String mname)
  2. getMethod(Object pojo, String methodName, Class[] params)
  3. getMethod(Object target, String methodName)
  4. getMethod(Object target, String methodName, Class... parameterTypes)
  5. getMethod(Object target, String signature)
  6. getMethodAnnotatedWith(final Class type, final Class annotation, String fieldName, Object fieldValue)
  7. getMethodByName(Object target, String methodName)
  8. getMethodConfigByAnnotaton(Object instance, Class declaringClass, Class annotationType, Class type)
  9. getMethodDescriptor(Object instance, String methodName, Class aClass, Class... parameters)