/** * For the given <code>Class</code> get a collection of the the {@link AnnotatedElement}s * that match the given <code>annotation</code>s or if no <code>annotation</code>s are * specified then return all of the annotated elements of the given <code>Class</code>. * Includes only the method level annotations. * * @param clazz The {@link Class} to inspect * @param annotation the {@link Annotation}s to find * @return A {@link Collection}<{@link AnnotatedElement}> containing all of the * method {@link AnnotatedElement}s matching the specified {@link Annotation}s */ public static Collection<Method> getAnnotatedMethods(Class clazz, Class<? extends Annotation>... annotation){ Collection<Method> toReturn = new HashSet<Method>(); for(Method m : clazz.getMethods()){ if( ArrayUtils.isNotEmpty(annotation) && isAnnotatedBy(m, annotation) ){ toReturn.add(m); }else if( ArrayUtils.isEmpty(annotation) && ArrayUtils.isNotEmpty(m.getAnnotations())){ toReturn.add(m); } } return toReturn; }