/** * Get an array of {@link Method}'s that matches the supplied list of method * names. Both instance and static methods are taken into account. * * @param clazz * The class that should contain the methods. * @param methodNames * Names of the methods that will be returned. * @return An array of Method's. * @throws MethodNotFoundException * If no method was found. */ public static Method[] getMethods(Class<?> clazz, String... methodNames) { return WhiteboxImpl.getMethods(clazz, methodNames); }
/** * Get an array of {@link Method}'s that matches the supplied list of method * names. Both instance and static methods are taken into account. * * @param clazz * The class that should contain the methods. * @param methodNames * Names of the methods that will be returned. * @return An array of Method's. * @throws MethodNotFoundException * If no method was found. */ public static Method[] getMethods(Class<?> clazz, String... methodNames) { return WhiteboxImpl.getMethods(clazz, methodNames); }
boolean exactParameterTypeMatch) { final Method foundMethod; final Method[] methods = getMethods(cls, methodName, signature, exactParameterTypeMatch); if (methods.length == 1) { foundMethod = methods[0];
/** * Gets the best method candidate. * * @param cls the cls * @param methodName the method name * @param signature the signature * @param exactParameterTypeMatch {@code true} if the {@code expectedTypes} must match * the parameter types must match exactly, {@code false} if * the {@code expectedTypes} are allowed to be converted * into primitive types if they are of a wrapped type and still * match. * @return the best method candidate */ public static Method getBestMethodCandidate(Class<?> cls, String methodName, Class<?>[] signature, boolean exactParameterTypeMatch) { final Method foundMethod; final Method[] methods = getMethods(cls, methodName, signature, exactParameterTypeMatch); if (methods.length == 1) { foundMethod = methods[0]; } else { // We've found overloaded methods, we need to find the best one to invoke. Arrays.sort(methods, ComparatorFactory.createMethodComparator()); foundMethod = methods[0]; } return foundMethod; }
boolean exactParameterTypeMatch) { List<Method> matchingArgumentTypes = new LinkedList<Method>(); Method[] methods = getMethods(clazz, methodName); for (Method method : methods) { final Class<?>[] parameterTypes = method.getParameterTypes();
boolean exactParameterTypeMatch) { List<Method> matchingArgumentTypes = new LinkedList<Method>(); Method[] methods = getMethods(clazz, methodName); for (Method method : methods) { final Class<?>[] parameterTypes = method.getParameterTypes();