Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (AnnotationMirror annotation : field.getAnnotationMirrors()) {
- Map<? extends ExecutableElement, ? extends AnnotationValue> annotationValueMap = annotation.getElementValues();
- messager.printMessage(Diagnostic.Kind.WARNING, annotation.toString() + ":" + annotationValueMap.toString());
- }
- @MyAnnotation:{}
- @MyAnnotation(max = 387, min = 66876, ...)
- private Integer myField;
- @Retention(RetentionPolicy.SOURCE)
- @Target(ElementType.FIELD)
- public @interface MyAnnotation {
- int max();
- boolean allowAuto();
- int min();
- }
- MyAnnotation myAnnotation= field.getAnnotation(MyAnnotation.class);
- int max = myAnnotation.max();
- int min = myAnnotation.min();
- for (AnnotationMirror annotation : field.getAnnotationMirrors()) {
- Map<? extends ExecutableElement, ? extends AnnotationValue> annotationValueMap = annotation.getElementValues();
- annotationValueMap.forEach((element, annotationValue) -> {
- messager.printMessage(Diagnostic.Kind.WARNING, element.getSimpleName().toString() + ":" + annotationValue.getValue());
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement