List of usage examples for javax.lang.model.util Elements getAllAnnotationMirrors
List<? extends AnnotationMirror> getAllAnnotationMirrors(Element e);
From source file:com.github.hexocraftapi.checkargs.processor.AnnotatedClass.java
/** * @param classElement TypeElement//from w w w. j av a2 s . c om * @param elementUtils TypeElement * @throws ClassNotFoundException ClassNotFoundException */ public AnnotatedClass(TypeElement classElement, Elements elementUtils) throws ClassNotFoundException { this.annotatedClassElement = classElement; CheckArgs annotation = classElement.getAnnotation(CheckArgs.class); List<? extends AnnotationMirror> annotationMirrors = elementUtils.getAllAnnotationMirrors(classElement); for (AnnotationMirror annotationMirror : annotationMirrors) { Map<? extends ExecutableElement, ? extends AnnotationValue> elementValues = annotationMirror .getElementValues(); for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : elementValues .entrySet()) { String key = entry.getKey().getSimpleName().toString(); Object value = entry.getValue().getValue(); switch (key) { case "count": this.count = (int) value; break; case "types": List<? extends AnnotationValue> typeMirrors = (List<? extends AnnotationValue>) value; for (AnnotationValue annotationValue : typeMirrors) { String clazz = annotationValue.getValue().toString(); this.qualifiedClassName.add(clazz); this.simpleClassName.add(clazz.substring(clazz.lastIndexOf(".") + 1)); } break; } } } if (this.qualifiedClassName.size() > 0 && this.count != this.qualifiedClassName.size()) this.count = this.qualifiedClassName.size(); }