Java Utililty Methods Reflection Method Name

List of utility methods to do Reflection Method Name

Description

The list of methods to do Reflection Method Name are organized into topic(s).

Method

MethodgetMethod(String methodName, Class klass)
Retorna o metodo de uma determinada classe.
for (Method method : klass.getDeclaredMethods()) {
    if (method.getName().equals(methodName)) {
        return method;
return null;
MethodgetMethod(String methodName, Class type)
get Method
try {
    Method method = type.getDeclaredMethod(methodName);
    if (!method.isAccessible()) {
        method.setAccessible(true);
    return method;
} catch (Exception e) {
    throw new UnsupportedOperationException(String.format(
...
MethodgetMethod(String methodName, Class[] paramTypes, Class targetClass)
get Method
try {
    return targetClass.getDeclaredMethod(methodName, paramTypes);
} catch (Exception e) {
    Class<?> superClass = targetClass.getSuperclass();
    if (superClass == null || superClass.equals(Object.class)) {
        return null;
    return getMethod(methodName, paramTypes, superClass);
...
MethodgetMethod(String methodName, Class[] params)
Returns the method object associated with the given method name.
if (m_cwc == null)
    m_cwc = Class.forName("com.jeta.forms.components.colors.JETAColorWell");
return m_cwc.getMethod(methodName, params);
MethodgetMethod(String methodName, Method method, boolean fromComponentType)
get Method
if (method == null) {
    return null;
try {
    Class<?> returnType = method.getReturnType();
    if (fromComponentType) {
        returnType = returnType.getComponentType();
    return returnType.getMethod(methodName);
} catch (Exception ex) {
    return null;
MethodgetMethod(String name, Class pojoClass)
get Method
StringBuffer getMethodName = new StringBuffer(GET);
getMethodName.append(name.substring(0, 1).toUpperCase());
getMethodName.append(name.substring(1));
return pojoClass.getMethod(getMethodName.toString(), new Class[] {});
StringgetMethod(String name, Method method)
get Method
if (method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == boolean.class) {
    if (name.length() > 1) {
        return "is" + Character.toUpperCase(name.charAt(0)) + name.substring(1);
    } else {
        return "is" + Character.toUpperCase(name.charAt(0));
if (name.length() > 1) {
...
MethodgetMethod(String name, String methodDesc, Class actual)
get Method
try {
    return actual.getMethod(name, argumentStringToClassArray(methodDesc, actual));
} catch (Exception e) {
    throw new RuntimeException(e);
MethodgetMethod(String strMethodPrefix, A instance, String strAttributeName, Class clazz)
Gets the method.
String strFirstLetter = strAttributeName.substring(0, 1).toUpperCase();
String strMethodName = strMethodPrefix + strFirstLetter
        + strAttributeName.substring(1, strAttributeName.length());
try {
    return instance.getClass().getMethod(strMethodName, new Class[] { clazz });
} catch (NoSuchMethodException e) {
    return getPrimitiveMethod(strMethodName, instance, clazz);
MethodgetMethodAsAccessible(String methodName, Class clazz)
get Method As Accessible
for (Method each : clazz.getDeclaredMethods()) {
    Method result = methodIsCorrectOrNull(methodName, each);
    if (result != null)
        return result;
for (Method each : clazz.getSuperclass().getDeclaredMethods()) {
    Method result = methodIsCorrectOrNull(methodName, each);
    if (result != null)
...