public static AnnotationMirror getAnnotationMirrorOfType(Element element, Class<? extends Annotation> annotation) {
        for (AnnotationMirror mirror : element.getAnnotationMirrors()) {
            if (mirror.getAnnotationType().toString().equals(annotation.getName())) {
                return mirror;
            }
        }
        return null;
    }
Various utility classes for {@link Element} and {@link AnnotationMirror} handling

@author tiwe
querydsl-apt/src/main/java/com/querydsl/apt/TypeUtils.java