Java Reflection Method Name getMethod(Class type, String methodName, Class... params)

Here you can find the source of getMethod(Class type, String methodName, Class... params)

Description

get Method

License

Open Source License

Declaration

static public <T> Method getMethod(Class<T> type, String methodName, Class<?>... params) 

Method Source Code

//package com.java2s;

import java.lang.reflect.Method;

public class Main {
    static public <T> Method getMethod(Class<T> type, String methodName, Class<?>... params) {
        if (type != null && methodName != null && methodName.length() > 0) {
            try {
                if (params != null && params.length > 0 && params[0] != null) {
                    return type.getMethod(methodName, params);
                } else {
                    return type.getMethod(methodName);
                }/*from  w  w  w  .j a  va 2 s  .  c  o  m*/
            } catch (NoSuchMethodException e) {
            }
        }
        return null;
    }
}

Related

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