Class<A> annotationType) { return getDeclaredRepeatableAnnotations(annotatedElement, annotationType, null);
Class<A> annotationType) { return getDeclaredRepeatableAnnotations(annotatedElement, annotationType, null);
Class<A> annotationType, @Nullable Class<? extends Annotation> containerAnnotationType) { Set<A> annotations = getDeclaredRepeatableAnnotations(annotatedElement, annotationType, containerAnnotationType); if (annotations.isEmpty() && annotatedElement instanceof Class) { Class<?> superclass = ((Class<?>) annotatedElement).getSuperclass();
Class<A> annotationType, @Nullable Class<? extends Annotation> containerAnnotationType) { Set<A> annotations = getDeclaredRepeatableAnnotations(annotatedElement, annotationType, containerAnnotationType); if (annotations.isEmpty() && annotatedElement instanceof Class) { Class<?> superclass = ((Class<?>) annotatedElement).getSuperclass();
@Test public void getDeclaredRepeatableAnnotationsDeclaredOnClass() { final List<String> expectedValuesJava = asList("A", "B", "C"); final List<String> expectedValuesSpring = asList("A", "B", "C", "meta1"); // Java 8 MyRepeatable[] array = MyRepeatableClass.class.getDeclaredAnnotationsByType(MyRepeatable.class); assertNotNull(array); List<String> values = stream(array).map(MyRepeatable::value).collect(toList()); assertThat(values, is(expectedValuesJava)); // Spring Set<MyRepeatable> set = getDeclaredRepeatableAnnotations(MyRepeatableClass.class, MyRepeatable.class, MyRepeatableContainer.class); assertNotNull(set); values = set.stream().map(MyRepeatable::value).collect(toList()); assertThat(values, is(expectedValuesSpring)); // When container type is omitted and therefore inferred from @Repeatable set = getDeclaredRepeatableAnnotations(MyRepeatableClass.class, MyRepeatable.class); assertNotNull(set); values = set.stream().map(MyRepeatable::value).collect(toList()); assertThat(values, is(expectedValuesSpring)); }
@Test public void getDeclaredRepeatableAnnotationsDeclaredOnSuperclass() { final Class<?> clazz = SubMyRepeatableClass.class; // Java 8 MyRepeatable[] array = clazz.getDeclaredAnnotationsByType(MyRepeatable.class); assertNotNull(array); assertThat(array.length, is(0)); // Spring Set<MyRepeatable> set = getDeclaredRepeatableAnnotations(clazz, MyRepeatable.class, MyRepeatableContainer.class); assertNotNull(set); assertThat(set.size(), is(0)); // When container type is omitted and therefore inferred from @Repeatable set = getDeclaredRepeatableAnnotations(clazz, MyRepeatable.class); assertNotNull(set); assertThat(set.size(), is(0)); }
private Set<Timed> findTimedAnnotations(AnnotatedElement element) { return AnnotationUtils.getDeclaredRepeatableAnnotations(element, Timed.class); }
private Set<Timed> findTimedAnnotations(AnnotatedElement element) { return AnnotationUtils.getDeclaredRepeatableAnnotations(element, Timed.class); }
Class<A> annotationType) { return getDeclaredRepeatableAnnotations(annotatedElement, annotationType, null);
Class<A> annotationType) { return getDeclaredRepeatableAnnotations(annotatedElement, annotationType, null);
Class<A> annotationType, @Nullable Class<? extends Annotation> containerAnnotationType) { Set<A> annotations = getDeclaredRepeatableAnnotations(annotatedElement, annotationType, containerAnnotationType); if (annotations.isEmpty() && annotatedElement instanceof Class) { Class<?> superclass = ((Class<?>) annotatedElement).getSuperclass();
Class<A> annotationType, @Nullable Class<? extends Annotation> containerAnnotationType) { Set<A> annotations = getDeclaredRepeatableAnnotations(annotatedElement, annotationType, containerAnnotationType); if (!annotations.isEmpty()) { return annotations;