use of java.lang.annotation.Repeatable in project mule by mulesoft.
the class MuleExtensionAnnotationParser method parseRepeatableAnnotation.
public static <T extends Annotation> List<T> parseRepeatableAnnotation(Class<?> extensionType, Class<T> annotation, Function<Annotation, T[]> containerConsumer) {
List<T> annotationDeclarations = ImmutableList.of();
Repeatable repeatableContainer = annotation.getAnnotation(Repeatable.class);
if (repeatableContainer != null) {
Annotation container = IntrospectionUtils.getAnnotation(extensionType, repeatableContainer.value());
if (container != null) {
annotationDeclarations = ImmutableList.copyOf(containerConsumer.apply(container));
}
}
T singleDeclaration = IntrospectionUtils.getAnnotation(extensionType, annotation);
if (singleDeclaration != null) {
annotationDeclarations = ImmutableList.of(singleDeclaration);
}
return annotationDeclarations;
}
use of java.lang.annotation.Repeatable in project spring-framework by spring-projects.
the class AnnotationUtilsTests method findRepeatableAnnotationOnComposedAnnotation.
@Test
public void findRepeatableAnnotationOnComposedAnnotation() {
Repeatable repeatable = findAnnotation(MyRepeatableMeta1.class, Repeatable.class);
assertNotNull(repeatable);
assertEquals(MyRepeatableContainer.class, repeatable.value());
}
use of java.lang.annotation.Repeatable in project graal by oracle.
the class AnnotationTypeFeature method afterRegistration.
@Override
public void afterRegistration(AfterRegistrationAccess access) {
ImageSingletons.add(AnnotationTypeSupport.class, new AnnotationTypeSupport());
((AfterRegistrationAccessImpl) access).getImageClassLoader().allAnnotations().stream().map(a -> a.getAnnotation(Repeatable.class)).filter(Objects::nonNull).map(Repeatable::value).forEach(repeatableAnnotationClasses::add);
}
use of java.lang.annotation.Repeatable in project core by weld.
the class Annotations method getRepeatableAnnotationAccessor.
/**
* Returns the value {@link Method} of a repeatable annotation container or null if the given annotation is not a repeatable
* annotation container.
* @param annotation the given annotation
* @return the value {@link Method} of a repeatable annotation container or null if the given annotation is not a repeatable
* annotation container
*/
public static Method getRepeatableAnnotationAccessor(Class<? extends Annotation> annotation) {
Method value;
if (System.getSecurityManager() == null) {
value = Reflections.findDeclaredMethodByName(annotation, VALUE_MEMBER_NAME);
} else {
value = doPrivileged(action(() -> Reflections.findDeclaredMethodByName(annotation, VALUE_MEMBER_NAME)));
}
if (value == null) {
return null;
}
if (!value.getReturnType().isArray()) {
return null;
}
Repeatable repeatable = value.getReturnType().getComponentType().getAnnotation(Repeatable.class);
if (repeatable == null) {
return null;
}
if (!repeatable.value().equals(annotation)) {
return null;
}
return value;
}
Aggregations