/** * Gets the signatures of all methods (public, private, protected, default) of the given instance or class. This includes as well * all methods (public, private, protected, default) of all its super classes. This does not include constructors. * * @param instanceOrClass the instance or class to get the method signatures of * @return the collection of method signatures of the given instance or class * * @see PrivilegedAccessor#getMethodSignatures(Object) */ public static Collection<String> getMethodSignatures(final Object instanceOrClass) { return PrivilegedAccessor.getMethodSignatures(instanceOrClass); }
/** * Gets the signatures of all methods (public, private, protected, default) of the given instance or class. This includes as well * all methods (public, private, protected, default) of all its super classes. This does not include constructors. * * @param instanceOrClass the instance or class to get the method signatures of * @return the collection of method signatures of the given instance or class */ public static Collection<String> getMethodSignatures(final Object instanceOrClass) { if (instanceOrClass == null) return Collections.EMPTY_LIST; Class<?> clazz = getClass(instanceOrClass); Method[] methods = clazz.getDeclaredMethods(); Collection<String> methodSignatures = new ArrayList<String>(methods.length + Object.class.getDeclaredMethods().length); for (Method method : methods) { methodSignatures.add(method.getName() + "(" + getParameterTypesAsString(method.getParameterTypes()) + ")"); } methodSignatures.addAll(getMethodSignatures(clazz.getSuperclass())); return methodSignatures; }