Example usage for org.springframework.core.annotation AnnotatedElementUtils findAllMergedAnnotations

List of usage examples for org.springframework.core.annotation AnnotatedElementUtils findAllMergedAnnotations

Introduction

In this page you can find the example usage for org.springframework.core.annotation AnnotatedElementUtils findAllMergedAnnotations.

Prototype

public static Set<Annotation> findAllMergedAnnotations(AnnotatedElement element,
        Set<Class<? extends Annotation>> annotationTypes) 

Source Link

Document

Find all annotations of the specified annotationTypes within the annotation hierarchy above the supplied element ; and for each annotation found, merge that annotation's attributes with matching attributes from annotations in lower levels of the annotation hierarchy and synthesize the results back into an annotation of the corresponding annotationType .

Usage

From source file:org.springframework.test.context.BootstrapUtils.java

@Nullable
private static Class<?> resolveExplicitTestContextBootstrapper(Class<?> testClass) {
    Set<BootstrapWith> annotations = AnnotatedElementUtils.findAllMergedAnnotations(testClass,
            BootstrapWith.class);
    if (annotations.isEmpty()) {
        return null;
    }/* w  w  w  .j  a va2s  . c  om*/
    Assert.state(annotations.size() <= 1, () -> String.format(
            "Configuration error: found multiple declarations of @BootstrapWith for test class [%s]: %s",
            testClass.getName(), annotations));
    return annotations.iterator().next().value();
}