public static void forEachAnnotations ( Element currentElement , AnnotationFilter filter , AnnotationFoundListener listener ) { final Elements elementUtils = BaseProcessor . elementUtils ; List < ? extends AnnotationMirror > annotationList = elementUtils . getAllAnnotationMirrors ( currentElement ) ; String annotationClassName ; // boolean valid=true; for ( AnnotationMirror annotation : annotationList ) { Map < String , String > values = new HashMap < String , String > ( ) ; annotationClassName = annotation . getAnnotationType ( ) . asElement ( ) . toString ( ) ; if ( filter != null && ! filter . isAccepted ( annotationClassName ) ) { continue ; } values . clear ( ) ; for ( Entry < ? extends ExecutableElement , ? extends AnnotationValue > annotationItem : elementUtils . getElementValuesWithDefaults ( annotation ) . entrySet ( ) ) { String value = annotationItem . getValue ( ) . toString ( ) ; if ( value . startsWith ( "\"" ) && value . endsWith ( "\"" ) ) { value = value . substring ( 1 ) ; value = value . substring ( 0 , value . length ( ) - 1 ) ; } values . put ( annotationItem . getKey ( ) . getSimpleName ( ) . toString ( ) , value ) ; } if ( listener != null ) { listener . onAcceptAnnotation ( currentElement , annotationClassName , values ) ; } } }
Iterate over annotations of currentElement . Accept only annotation in accepted set .