private Method findPublicVoidMethod(Class<?> aClass, String methodName) { for (Method method : aClass.getDeclaredMethods()) { if (isPublic(method.getModifiers()) && method.getReturnType() == void.class && methodName.equals(method.getName())) { return method; } } return null; }
private ArrayList<Object> gatherParamsFromAllMethodsFrom(Class<?> sourceClass) { ArrayList<Object> result = new ArrayList<Object>(); Method[] methods = sourceClass.getDeclaredMethods(); for (Method method : methods) { if (method.getName().startsWith("provide")) { if (!Modifier.isStatic(method.getModifiers())) throw new RuntimeException( "Parameters source method " + method.getName() + " is not declared as static. Modify it to a static method."); try { result.addAll(Arrays.asList(processParamsIfSingle((Object[]) method.invoke(null)))); } catch (Exception e) { throw new RuntimeException( "Cannot invoke parameters source method: " + method.getName(), e); } } } return result; }