Java Reflection Method Name getMethod(Class clazz, String methodName)

Here you can find the source of getMethod(Class clazz, String methodName)

Description

get Method

License

Apache License

Declaration

public static <T> Method getMethod(Class<T> clazz, String methodName) 

Method Source Code

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

import java.lang.reflect.Method;

public class Main {

    public static <T> Method getMethod(Class<T> clazz, String methodName) {
        Method[] methods = clazz.getDeclaredMethods();
        for (Method m : methods) {
            if (m.getName().equals(methodName)) {
                return m;
            }/*  w w w .java 2  s. c  o  m*/
        }
        methods = clazz.getSuperclass().getDeclaredMethods();
        for (Method m : methods) {
            if (m.getName().equals(methodName)) {
                return m;
            }
        }
        return null;
    }
}

Related

  1. getMethod(Class klass, String methodName, Class requestClass)
  2. getMethod(Class klass, String methodName, Class... paramTypes)
  3. getMethod(Class klass, String name, String name2)
  4. getMethod(Class theClass, String methodName, Class[] paramTypes)
  5. getMethod(Class c, String name, Class... argTypes)
  6. getMethod(Class clazz, String methodName, Class[] calledTypes)
  7. getMethod(Class type, String methodName, Class... params)
  8. getMethod(final Class atClass, final String name, final Class[] paramType)
  9. getMethod(final Class clazz, final String methodName, final boolean factoryMethod, final boolean failIfNotFound)