List of utility methods to do Reflection Method Name
String | getMethodName(String prefix, String fieldName) get Method Name return prefix + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
|
String | getMethodNameAndDescriptor(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(); ... |
HashMap | getMethodNameList(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(); ... |
String | getMethodNameMinusGet(Method aMethod) get Method Name Minus Get String result = aMethod.getName(); if (result.startsWith(fGET)) { result = result.substring(fGET.length()); return result; |
Vector | getMethodNames(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; |
String | getMethodNameWithClassName(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("."); ... |
Method | getMethodOnlyByName(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) { ... |
Method | getMethodOrNull(Class cls, String name, Class[] args) Get a method using reflections. try { return cls.getMethod(name, args); } catch (NoSuchMethodException nsme) { return null; |
String | getMethodPropertyName(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); |