List of utility methods to do Reflection Method Signature
String | getMethodSignature(Method method) get Method Signature String genericString = method.toGenericString(); String declaringClassName = method.getDeclaringClass().getName(); int a = genericString.indexOf(" " + declaringClassName + "."); int b = genericString.lastIndexOf(')'); return genericString.substring(a + declaringClassName.length() + 2, b + 1); |
String | getMethodSignature(Method method) get Method Signature StringBuilder sb = new StringBuilder(); sb.append(method.getName()); sb.append('('); boolean firstParameter = true; for (Class<?> parameterType : method.getParameterTypes()) { if (!firstParameter) { sb.append(','); firstParameter = false; sb.append(getClassName(parameterType)); sb.append(')'); return sb.toString(); |
String | getMethodSignature(Method method) get Method Signature StringBuilder sb = new StringBuilder(); if (method.getReturnType() != null) { sb.append(method.getReturnType().getName()).append("#"); sb.append(method.getName()); Class<?>[] parameterTypes = method.getParameterTypes(); if (parameterTypes != null) { for (int i = 0, length = parameterTypes.length; i < length; i++) { ... |
String | getMethodSignatureWithLongTypeNames(Method method) get Method Signature With Long Type Names return getSignature(method, true);
|
Method | getMethodWithSignature(Class> clazz, String methodName, Class>[] params) get Method With Signature Method resultMethod = null; Method[] allMethods = clazz.getDeclaredMethods(); if (params == null) { params = new Class[0]; for (Method method : allMethods) { if (method.getName().equals(methodName)) { Class<?> methodParams[] = method.getParameterTypes(); ... |