Java Reflection Method Name getMethodByName(Class aClass, String methodName, Class... params)

Here you can find the source of getMethodByName(Class aClass, String methodName, Class... params)

Description

Retrieves a method by name (grabs the first if overloaded).

License

Open Source License

Parameter

Parameter Description
methodName a parameter

Return

the method if found, otherwise null

Declaration

public static Method getMethodByName(Class<?> aClass, String methodName, Class<?>... params) 

Method Source Code

//package com.java2s;
/*/*  w ww.j a v a  2 s.c  om*/
   Leola Programming Language
   Author: Tony Sparks
   See license.txt
*/

import java.lang.reflect.Method;

public class Main {
    /**
     * Retrieves a method by name (grabs the first if overloaded).
     *
     * @param methodName
     * @return the method if found, otherwise null
     */
    public static Method getMethodByName(Class<?> aClass, String methodName, Class<?>... params) {
        Method result = null;
        try {
            result = aClass.getMethod(methodName, params);
        } catch (Exception e) {
        }

        return (result);
    }
}

Related

  1. getMethod(String name, Method method)
  2. getMethod(String name, String methodDesc, Class actual)
  3. getMethod(String strMethodPrefix, A instance, String strAttributeName, Class clazz)
  4. getMethodAsAccessible(String methodName, Class clazz)
  5. getMethodByName(Class clazz, String methodName)
  6. getMethodByName(Class clazz, String methodName)
  7. getMethodByName(Class clazz, String methodName)
  8. getMethodByName(Class clazz, String name)
  9. getMethodByName(Class cls, String methodName)