Java examples for java.lang.annotation:Annotation Attribute
has Annotation With Name
//package com.java2s; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; public class Main { public static boolean hasAnnotationWithName(Element element, String simpleName) {/* w ww . java 2s. c o m*/ for (AnnotationMirror mirror : element.getAnnotationMirrors()) { String annotationName = mirror.getAnnotationType().asElement() .getSimpleName().toString(); if (simpleName.equals(annotationName)) { return true; } } return false; } }