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

StringgetMethodName(String prefix, String fieldName)
get Method Name
return prefix + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
StringgetMethodNameAndDescriptor(Method m)
Returns a string consisting of the given method's name followed by its "method descriptor", as appropriate for use in the computation of the "method hash".
StringBuffer desc = new StringBuffer(m.getName());
desc.append('(');
Class[] paramTypes = m.getParameterTypes();
for (int i = 0; i < paramTypes.length; i++) {
    desc.append(getTypeDescriptor(paramTypes[i]));
desc.append(')');
Class returnType = m.getReturnType();
...
HashMapgetMethodNameList(Class theClass)
getMethodNameList
HashMap<String, Integer> methodsAndParams = new HashMap<String, Integer>();
String className = theClass.getCanonicalName();
Method[] classMethods = theClass.getDeclaredMethods();
String currMethodCanonicalName = "";
String currMethodName = "";
int currMethodNumberParams = 0;
for (int i = 0; i < classMethods.length; i++) {
    currMethodCanonicalName = classMethods[i].toString();
...
StringgetMethodNameMinusGet(Method aMethod)
get Method Name Minus Get
String result = aMethod.getName();
if (result.startsWith(fGET)) {
    result = result.substring(fGET.length());
return result;
VectorgetMethodNames(Class cls, boolean insertDefaultValues)
Returns a Vector of String s that are the full Method names, with parameters for the given class.
Method[] methodsArray = cls.getMethods();
Vector methods = new Vector(methodsArray.length);
for (int i = 0; i < methodsArray.length; i++) {
    String term = getMethodName(methodsArray[i], insertDefaultValues);
    methods.add(term);
return methods;
String[]getMethodNames(Class cls)
Gets all methodnames from the given class as an String array.
Method[] methods = cls.getDeclaredMethods();
String[] methodNames = new String[methods.length];
for (int i = 0; i < methods.length; i++) {
    methodNames[i] = methods[i].getName();
return methodNames;
StringgetMethodNameWithClassName(Method a_Method)
Return method name from Method object
if (a_Method == null) {
    throw new NullPointerException("Parameter method is null");
StringBuffer l_StringBuffer = new StringBuffer();
l_StringBuffer.append(a_Method.getReturnType().getName());
l_StringBuffer.append(" ");
l_StringBuffer.append(a_Method.getDeclaringClass().getName());
l_StringBuffer.append(".");
...
MethodgetMethodOnlyByName(Class c, String methodName)
Searches in the given class for the given method name.
Method method = null;
for (Method m : c.getMethods()) {
    if (m.getName().equals(methodName)) {
        method = m;
        break;
if (method == null) {
...
MethodgetMethodOrNull(Class cls, String name, Class[] args)
Get a method using reflections.
try {
    return cls.getMethod(name, args);
} catch (NoSuchMethodException nsme) {
    return null;
StringgetMethodPropertyName(java.lang.reflect.Method method)
get Method Property Name
final String methodName = method.getName();
if (methodName.startsWith("get") && methodName.length() > 3) {
    return uncapitalize(methodName.substring(3, methodName.length()));
} else {
    throw new RuntimeException("Incorrect getter name: " + methodName);