private static List < Method > getMethodsWithAnnotation ( Class < ? > clazz , Class < ? extends Annotation > annotation , Logger log ) { List < Method > annotatedMethods = new ArrayList < Method > ( ) ; Method classMethods [ ] = clazz . getDeclaredMethods ( ) ; for ( Method classMethod : classMethods ) { if ( classMethod . isAnnotationPresent ( annotation ) && classMethod . getParameterTypes ( ) . length == 0 ) { if ( ! containsMethod ( classMethod , annotatedMethods ) ) { annotatedMethods . add ( classMethod ) ; } } } Collections . sort ( annotatedMethods , new Comparator < Method > ( ) { @ Override public int compare ( Method method1 , Method method2 ) { return method1 . getName ( ) . compareTo ( method2 . getName ( ) ) ; } } ) ; return annotatedMethods ; }
Locates all methods annotated with a given annotation that are declared directly in the class passed in alphabetical order .