KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > spoon > support > query > AnnotationFilter


1 package spoon.support.query;
2
3 import java.lang.annotation.Annotation JavaDoc;
4
5 import spoon.reflect.declaration.CtElement;
6
7 /**
8  * This filter matches all the elements annotated with a given annotation type.
9  */

10 public class AnnotationFilter<E extends CtElement> extends AbstractFilter<E> {
11     Class JavaDoc<? extends Annotation JavaDoc> annotationType;
12
13     public AnnotationFilter(Class JavaDoc<? extends Annotation JavaDoc> annotationType){
14         super(CtElement.class);
15         this.annotationType=annotationType;
16     }
17     
18     /**
19      * Creates a new annotation filter.
20      */

21     public AnnotationFilter(Class JavaDoc<E> elementType,Class JavaDoc<? extends Annotation JavaDoc> annotationType) {
22         super(elementType);
23         this.annotationType=annotationType;
24     }
25
26     public boolean matches(E element) {
27         return element.getAnnotation(annotationType)!=null;
28     }
29 }
Popular Tags