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

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

Description

get Method

License

Apache License

Declaration

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

Method Source Code

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

import java.lang.reflect.Method;

public class Main {
    public static Method getMethod(String methodName, Class<?> type) {
        try {/*www  . j  a  v a 2  s .  c  o m*/
            Method method = type.getDeclaredMethod(methodName);
            if (!method.isAccessible()) {
                method.setAccessible(true);
            }
            return method;
        } catch (Exception e) {
            throw new UnsupportedOperationException(String.format(
                    "Method %s could not be proccessed. Check if this method is accessible.", methodName), e);
        }
    }
}

Related

  1. getMethod(String className, String functionName, Class[] paramTypes)
  2. getMethod(String className, String methodName, Class[] params)
  3. getMethod(String methodName, Class clazz)
  4. getMethod(String methodName, Class clazz, Class... args)
  5. getMethod(String methodName, Class klass)
  6. getMethod(String methodName, Class[] paramTypes, Class targetClass)
  7. getMethod(String methodName, Class[] params)
  8. getMethod(String methodName, Method method, boolean fromComponentType)
  9. getMethod(String name, Class pojoClass)