T
- the type of result returned by the processorprivate static interface AnnotatedElementUtils.Processor<T>
Depending on the use case, a processor may choose to
process(java.lang.reflect.AnnotatedElement, java.lang.annotation.Annotation, int) a single target annotation, multiple target
annotations, or all annotations discovered by the currently executing
search. The term "target" in this context refers to a matching
annotation (i.e., a specific annotation type that was found during
the search). Returning a non-null value from the process(java.lang.reflect.AnnotatedElement, java.lang.annotation.Annotation, int)
method instructs the search algorithm to stop searching further;
whereas, returning null
from the process(java.lang.reflect.AnnotatedElement, java.lang.annotation.Annotation, int)
method
instructs the search algorithm to continue searching for additional
annotations.
Processors can optionally post-process
the result of the process(java.lang.reflect.AnnotatedElement, java.lang.annotation.Annotation, int)
method as the search algorithm
goes back down the annotation hierarchy from an invocation of
process(java.lang.reflect.AnnotatedElement, java.lang.annotation.Annotation, int)
that returned a non-null value down to the
AnnotatedElement
that was supplied as the starting point to
the search algorithm.
Modifier and Type | Method and Description |
---|---|
void |
postProcess(java.lang.reflect.AnnotatedElement annotatedElement,
java.lang.annotation.Annotation annotation,
T result)
Post-process the result returned by the
process(java.lang.reflect.AnnotatedElement, java.lang.annotation.Annotation, int) method. |
T |
process(java.lang.reflect.AnnotatedElement annotatedElement,
java.lang.annotation.Annotation annotation,
int metaDepth)
Process the supplied annotation.
|
T process(java.lang.reflect.AnnotatedElement annotatedElement, java.lang.annotation.Annotation annotation, int metaDepth)
Depending on the use case, the supplied annotation may be an
actual target annotation that has been found by the search
algorithm, or it may be some other annotation within the
annotation hierarchy. In the latter case, the metaDepth
should have a value greater than 0
. In any case, it is
up to concrete implementations of this method to decide what to
do with the supplied annotation.
The metaDepth
parameter represents the depth of the
annotation relative to the first annotated element in the
annotation hierarchy. For example, an annotation that is
present on a non-annotation element will have a depth
of 0; a meta-annotation will have a depth of 1; and a
meta-meta-annotation will have a depth of 2; etc.
annotatedElement
- the element that is annotated with the
supplied annotation, used for contextual logging; may be
null
if unknownannotation
- the annotation to processmetaDepth
- the meta-depth of the annotationnull
to continue
searching for additional annotationsvoid postProcess(java.lang.reflect.AnnotatedElement annotatedElement, java.lang.annotation.Annotation annotation, T result)
process(java.lang.reflect.AnnotatedElement, java.lang.annotation.Annotation, int)
method.
The annotation
supplied to this method is an annotation
that is present in the annotation hierarchy, between the initial
AnnotatedElement
and an invocation of process(java.lang.reflect.AnnotatedElement, java.lang.annotation.Annotation, int)
that returned a non-null value.
annotatedElement
- the element that is annotated with the
supplied annotation, used for contextual logging; may be
null
if unknownannotation
- the annotation to post-processresult
- the result to post-process