MethodHelper { public static List<ParameterInfo> getParameterInfos(final Method method) { final Class<?>[] parameterTypes = method.getParameterTypes(); final Annotation[][] parameterAnnotations = parameterAnnotationsOf(method); final String[] parameterNames = parameterNamesOf(method); final List<ParameterInfo> parameterInfos = new ArrayList<ParameterInfo>(); for (int i=0,n=parameterNames.length; i<n; ++i) { parameterInfos.add(new ParameterInfo( parameterNames[i], parameterTypes[i], parameterAnnotations.length > i ? asList(parameterAnnotations[i]) : Collections.<Annotation>emptyList()) ); } return parameterInfos; }  static List<ParameterInfo> getParameterInfos(final Method method); static String[] parameterNamesOf(final Method method); static final Annotation[][] EMPTY_ANNOTATIONS; }
@Test public void methodWithAnnotatedParam() throws Exception{ final Method method = Fixture.class.getMethod("methodWithAnnotatedParam", int.class); final List<ParameterInfo> parameterInfos = MethodHelper.getParameterInfos(method); assertEquals(parameterInfos.size(), 1); assertEquals(parameterInfos.get(0).getName(), "foo"); assertEquals(parameterInfos.get(0).getType(), int.class); assertEquals(parameterInfos.get(0).getAnnotations().size(), 1); assertEquals(parameterInfos.get(0).getAnnotations().get(0).annotationType(), Doc.class); }