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

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

Description

get Method

License

Apache License

Declaration

public static Method getMethod(Object o, String methodName) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.lang.reflect.Method;

public class Main {
    public static Method getMethod(Object o, String methodName) {
        if ((methodName == null) || (o == null)) {
            return null;
        }/*from   w w  w .j  a  v  a  2 s.co m*/
        Method[] ms = o.getClass().getMethods();
        for (int i = 0; i < ms.length; i++) {
            Method m = ms[i];
            if (m.getName().equals(methodName)) {
                return m;
            }
        }
        return null;
    }
}

Related

  1. getMethod(final Object target, final String methodName, final Class... argumentTypes)
  2. getMethod(final String methodName, final Object obj, final Class... argTypes)
  3. getMethod(Object bean, String propertyName)
  4. getMethod(Object instance, String methodName, Class... argsClass)
  5. getMethod(Object instance, String methodName, Class[] parameters)
  6. getMethod(Object o, String methodName, Class[] args)
  7. getMethod(Object o, String methodName, Class[] paramTypes)
  8. getMethod(Object obj, Class[] paramTypes, String methodName)
  9. getMethod(Object obj, String fieldName)