@Test void testFindAttributesOnStaticMetaAnnotation() throws NoSuchMethodException { Map<String, Object> results = AnnotationUtils.findAnnotationAttributes(getClass().getDeclaredMethod("staticallyOverridden"), TheTarget.class).get(); assertEquals("overridden_statically", results.get("property")); }
public static Optional<Map<String, Object>> findAnnotationAttributes(AnnotatedElement element, String annotationName) { Map<String, Object> attributes = new HashMap<>(); Annotation ann = getAnnotation(element, annotationName); boolean found = false; if (ann != null) { collectAttributes(ann, attributes); found = true; } else { HashSet<String> visited = new HashSet<>(); for (Annotation metaAnn : element.getAnnotations()) { if (collectAnnotationAttributes(metaAnn.annotationType(), annotationName, visited, attributes)) { found = true; collectAttributes(metaAnn, attributes); } } } return found ? Optional.of(attributes) : Optional.empty(); }
AnnotationUtils { public static Optional<Map<String, Object>> findAnnotationAttributes(AnnotatedElement element, String annotationName) { Map<String, Object> attributes = new HashMap<>(); Annotation ann = getAnnotation(element, annotationName); boolean found = false; if (ann != null) { collectAttributes(ann, attributes); found = true; } else { HashSet<String> visited = new HashSet<>(); for (Annotation metaAnn : element.getAnnotations()) { if (collectAnnotationAttributes(metaAnn.annotationType(), annotationName, visited, attributes)) { found = true; collectAttributes(metaAnn, attributes); } } } return found ? Optional.of(attributes) : Optional.empty(); } }
AnnotationUtils { public static Optional<Map<String, Object>> findAnnotationAttributes(AnnotatedElement element, String annotationName) { Map<String, Object> attributes = new HashMap<>(); Annotation ann = getAnnotation(element, annotationName); boolean found = false; if (ann != null) { collectAttributes(ann, attributes); found = true; } else { HashSet<String> visited = new HashSet<>(); for (Annotation metaAnn : element.getAnnotations()) { if (collectAnnotationAttributes(metaAnn.annotationType(), annotationName, visited, attributes)) { found = true; collectAttributes(metaAnn, attributes); } } } return found ? Optional.of(attributes) : Optional.empty(); } private  AnnotationUtils(); }
AnnotationUtils { public static Optional<Map<String, Object>> findAnnotationAttributes(AnnotatedElement element, String annotationName) { Map<String, Object> attributes = new HashMap<>(); Annotation ann = getAnnotation(element, annotationName); boolean found = false; if (ann != null) { collectAttributes(ann, attributes); found = true; } else { HashSet<String> visited = new HashSet<>(); for (Annotation metaAnn : element.getAnnotations()) { if (collectAnnotationAttributes(metaAnn.annotationType(), annotationName, visited, attributes)) { found = true; collectAttributes(metaAnn, attributes); } } } return found ? Optional.of(attributes) : Optional.empty(); } private  AnnotationUtils(); static boolean isAnnotationPresent(AnnotatedElement element, Class<? extends Annotation> annotationType); static boolean isAnnotationPresent(AnnotatedElement element, String annotationType); static Optional<Map<String, Object>> findAnnotationAttributes(AnnotatedElement element, String annotationName); static Optional<Map<String, Object>> findAnnotationAttributes(AnnotatedElement element,
                                                                         Class<? extends Annotation> annotationType); @SuppressWarnings("unchecked") static Optional<T> findAnnotationAttribute(AnnotatedElement element,
                                                          Class<? extends Annotation> annotationType,
                                                          String attributeName); }
AnnotationUtils { public static Optional<Map<String, Object>> findAnnotationAttributes(AnnotatedElement element, String annotationName) { Map<String, Object> attributes = new HashMap<>(); Annotation ann = getAnnotation(element, annotationName); boolean found = false; if (ann != null) { collectAttributes(ann, attributes); found = true; } else { HashSet<String> visited = new HashSet<>(); for (Annotation metaAnn : element.getAnnotations()) { if (collectAnnotationAttributes(metaAnn.annotationType(), annotationName, visited, attributes)) { found = true; collectAttributes(metaAnn, attributes); } } } return found ? Optional.of(attributes) : Optional.empty(); } private  AnnotationUtils(); static boolean isAnnotationPresent(AnnotatedElement element, Class<? extends Annotation> annotationType); static boolean isAnnotationPresent(AnnotatedElement element, String annotationType); static Optional<Map<String, Object>> findAnnotationAttributes(AnnotatedElement element, String annotationName); static Optional<Map<String, Object>> findAnnotationAttributes(AnnotatedElement element,
                                                                         Class<? extends Annotation> annotationType); @SuppressWarnings("unchecked") static Optional<T> findAnnotationAttribute(AnnotatedElement element,
                                                          Class<? extends Annotation> annotationType,
                                                          String attributeName);  }