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

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

Description

get Method

License

Open Source License

Declaration

public static Method getMethod(String name, Class<?> pojoClass) throws Exception 

Method Source Code

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

import java.lang.reflect.Method;

public class Main {
    public static String GET = "get";
    public static String SET = "set";

    public static Method getMethod(String name, Class<?> pojoClass) throws Exception {
        StringBuffer getMethodName = new StringBuffer(GET);
        getMethodName.append(name.substring(0, 1).toUpperCase());
        getMethodName.append(name.substring(1));
        return pojoClass.getMethod(getMethodName.toString(), new Class[] {});
    }//  w  w  w.j a  v a  2 s .  c  o  m

    public static Method getMethod(String name, Class<?> pojoClass, Class<?> type) throws Exception {
        StringBuffer getMethodName = new StringBuffer(SET);
        getMethodName.append(name.substring(0, 1).toUpperCase());
        getMethodName.append(name.substring(1));
        return pojoClass.getMethod(getMethodName.toString(), new Class[] { type });
    }
}

Related

  1. getMethod(String methodName, Class klass)
  2. getMethod(String methodName, Class type)
  3. getMethod(String methodName, Class[] paramTypes, Class targetClass)
  4. getMethod(String methodName, Class[] params)
  5. getMethod(String methodName, Method method, boolean fromComponentType)
  6. getMethod(String name, Method method)
  7. getMethod(String name, String methodDesc, Class actual)
  8. getMethod(String strMethodPrefix, A instance, String strAttributeName, Class clazz)
  9. getMethodAsAccessible(String methodName, Class clazz)