Java Reflection Method Name getMethod(Class clz, String name)

Here you can find the source of getMethod(Class clz, String name)

Description

get Method

License

Apache License

Declaration

protected static Method getMethod(Class<?> clz, String name) throws NoSuchMethodException 

Method Source Code

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

import java.lang.reflect.Method;

public class Main {
    protected static Method getMethod(Class<?> clz, String name) throws NoSuchMethodException {
        return clz.getMethod("get" + name);
    }//from  w ww .j a  va 2 s.c  om

    protected static Method getMethod(Class<?> clz, String name, Object value) throws NoSuchMethodException {
        Method method = null;
        try {
            method = getMethod(clz, name);
        } catch (NoSuchMethodException nsme) {
            if (Boolean.class.equals(value.getClass())) {
                method = clz.getMethod("is" + name);
            } else {
                throw nsme;
            }
        }
        return method;
    }
}

Related

  1. getMethod(Class clazz, String... names)
  2. getMethod(Class cls, String name)
  3. getMethod(Class cls, String name)
  4. getMethod(Class cls, String name, Class... types)
  5. getMethod(Class clss, String name, Class... params)
  6. getMethod(Class klass, String methodName)
  7. getMethod(Class klass, String methodName, Class requestClass)
  8. getMethod(Class klass, String methodName, Class... paramTypes)
  9. getMethod(Class klass, String name, String name2)