类 MergedAnnotations.Search
java.lang.Object
cn.taketoday.core.annotation.MergedAnnotations.Search
- 封闭接口:
- MergedAnnotations
Fluent API for configuring the search algorithm used in the
MergedAnnotations model and performing a search.
- Configuration starts with an invocation of
MergedAnnotations.search(SearchStrategy), specifying whichMergedAnnotations.SearchStrategyto use. - Optional configuration can be provided via one of the
with*()methods. - The actual search is performed by invoking
from(AnnotatedElement)with the source element from which the search should begin.
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
-
方法概要
修饰符和类型方法说明from(AnnotatedElement element) Perform a search for merged annotations beginning with the suppliedAnnotatedElement(such as aClassorMethod), using the configuration in thisSearchinstance.withAnnotationFilter(AnnotationFilter annotationFilter) Configure theAnnotationFilterto use.withRepeatableContainers(RepeatableContainers repeatableContainers) Configure theRepeatableContainersto use.
-
方法详细资料
-
withRepeatableContainers
Configure theRepeatableContainersto use.Defaults to
RepeatableContainers.standard().- 参数:
repeatableContainers- the repeatable containers that may be used by annotations or meta-annotations- 返回:
- this
Searchinstance for chained method invocations - 另请参阅:
-
withAnnotationFilter
Configure theAnnotationFilterto use.Defaults to
AnnotationFilter.PLAIN.- 参数:
annotationFilter- an annotation filter used to restrict the annotations considered- 返回:
- this
Searchinstance for chained method invocations - 另请参阅:
-
from
Perform a search for merged annotations beginning with the suppliedAnnotatedElement(such as aClassorMethod), using the configuration in thisSearchinstance.- 参数:
element- the source element- 返回:
- a new
MergedAnnotationsinstance containing all annotations and meta-annotations from the specified element and, depending on theMergedAnnotations.SearchStrategy, related inherited elements - 另请参阅:
-