Class MergedAnnotations.Search

java.lang.Object
org.springframework.core.annotation.MergedAnnotations.Search
Enclosing interface:
MergedAnnotations

public static final class MergedAnnotations.Search extends Object
Fluent API for configuring the search algorithm used in the MergedAnnotations model and performing a search.

For example, the following performs a search on MyClass within the entire type hierarchy of that class while ignoring repeatable annotations.

 MergedAnnotations mergedAnnotations =
     MergedAnnotations.search(SearchStrategy.TYPE_HIERARCHY)
         .withRepeatableContainers(RepeatableContainers.none())
         .from(MyClass.class);
 

If you wish to reuse search configuration to perform the same type of search on multiple elements, you can save the Search instance as demonstrated in the following example.

 Search search = MergedAnnotations.search(SearchStrategy.TYPE_HIERARCHY)
                     .withRepeatableContainers(RepeatableContainers.none());

 MergedAnnotations mergedAnnotations = search.from(MyClass.class);
 // do something with the MergedAnnotations for MyClass
 mergedAnnotations = search.from(AnotherClass.class);
 // do something with the MergedAnnotations for AnotherClass
 
Since:
6.0