Java Reflection Method Name getMethod(Class clazz, String... names)

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

Description

get Method

License

Open Source License

Declaration

public static Method getMethod(Class<?> clazz, String... names) 

Method Source Code

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

import java.lang.reflect.Method;

public class Main {
    public static Method getMethod(Class<?> clazz, String... names) {
        try {/*from w  ww  . jav a 2 s.  co m*/
            Method[] methods = clazz.getDeclaredMethods();
            for (Method method : methods) {
                for (String methodName : names) {
                    if (method.getName().equalsIgnoreCase(methodName)) {
                        method.setAccessible(true);
                        return method;
                    }
                }
            }
        } catch (Exception e) {
            throw e;
        }
        return null;
    }
}

Related

  1. getMethod(Class clazz, String name, boolean declared, Class... args)
  2. getMethod(Class clazz, String name, Class... args)
  3. getMethod(Class clazz, String name, Class... args)
  4. getMethod(Class clazz, String name, Class... params)
  5. getMethod(Class clazz, String name, int paramlength)
  6. getMethod(Class cls, String name)
  7. getMethod(Class cls, String name)
  8. getMethod(Class cls, String name, Class... types)
  9. getMethod(Class clss, String name, Class... params)