Java Reflection Method Parameter getMethod(String classFullName, String methodName, Class... parameterTypes)

Here you can find the source of getMethod(String classFullName, String methodName, Class... parameterTypes)

Description

get Method

License

Open Source License

Declaration

public static Method getMethod(String classFullName, String methodName, Class<?>... parameterTypes) 

Method Source Code

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

import java.lang.reflect.Method;

public class Main {
    public static Method getMethod(String classFullName, String methodName, Class<?>... parameterTypes) {
        Class<?> cls = getClass(classFullName);

        if (cls == null || "".equals(methodName)) {
            return null;
        }/*from  w w  w . ja  v a  2s. c  om*/

        Method method = null;

        try {
            method = cls.getDeclaredMethod(methodName, parameterTypes);
        } catch (SecurityException | NoSuchMethodException e) {
            System.out.println(e.getMessage());
        }

        return method;
    }

    private static Class<?> getClass(String classFullName) {
        Class<?> cls = null;
        try {
            cls = Class.forName(classFullName);
        } catch (ClassNotFoundException e) {
            System.out.println(e.getMessage());
        }
        return cls;
    }
}

Related

  1. getMethod(final Class clazz, final String name, final Class... parametertypes)
  2. getMethod(final Class clazz, final String name, final Class... parameterTypes)
  3. getMethod(final Class target, final String name, final Class... parameters)
  4. getMethod(final Class receiver, final String methodName, final Class... parameterTypes)
  5. getMethod(final Field visitee, final String methodName, final Class... parameterTypes)
  6. getMethod0(Class c, String name, Class... parameterTypes)
  7. getMethod0(Class target, String name, Class[] parameterTypes)
  8. getMethodAnnotations(String className, String methodName, Class[] parameterTypes)
  9. getMethodByName(Class clazz, String name, Class... parameterTypes)