private static class AnnotatedElementUtils.MergedAnnotationAttributesProcessor extends java.lang.Object implements AnnotatedElementUtils.Processor<AnnotationAttributes>
AnnotatedElementUtils.Processor
that gets the AnnotationAttributes
for the
target annotation during the process(java.lang.reflect.AnnotatedElement, java.lang.annotation.Annotation, int)
phase and then merges
annotation attributes from lower levels in the annotation hierarchy
during the postProcess(java.lang.reflect.AnnotatedElement, java.lang.annotation.Annotation, org.springframework.core.annotation.AnnotationAttributes)
phase.
A MergedAnnotationAttributesProcessor
may optionally be
configured to aggregate results.
Modifier and Type | Field and Description |
---|---|
private java.util.List<AnnotationAttributes> |
aggregatedResults |
private boolean |
aggregates |
private boolean |
classValuesAsString |
private boolean |
nestedAnnotationsAsMap |
Constructor and Description |
---|
MergedAnnotationAttributesProcessor() |
MergedAnnotationAttributesProcessor(boolean classValuesAsString,
boolean nestedAnnotationsAsMap) |
MergedAnnotationAttributesProcessor(boolean classValuesAsString,
boolean nestedAnnotationsAsMap,
boolean aggregates) |
Modifier and Type | Method and Description |
---|---|
boolean |
aggregates()
Determine if this processor aggregates the results returned by
AnnotatedElementUtils.Processor.process(java.lang.reflect.AnnotatedElement, java.lang.annotation.Annotation, int) . |
boolean |
alwaysProcesses()
Determine if this processor always processes annotations regardless of
whether or not the target annotation has been found.
|
private java.lang.Object |
getAdaptedValue(java.lang.reflect.AnnotatedElement element,
java.lang.annotation.Annotation annotation,
java.lang.String sourceAttributeName) |
java.util.List<AnnotationAttributes> |
getAggregatedResults()
Get the list of results aggregated by this processor.
|
private void |
overrideAttribute(java.lang.reflect.AnnotatedElement element,
java.lang.annotation.Annotation annotation,
AnnotationAttributes attributes,
java.lang.String sourceAttributeName,
java.lang.String targetAttributeName) |
private void |
overrideAttributes(java.lang.reflect.AnnotatedElement element,
java.lang.annotation.Annotation annotation,
AnnotationAttributes attributes,
java.lang.String sourceAttributeName,
java.util.List<java.lang.String> targetAttributeNames) |
void |
postProcess(java.lang.reflect.AnnotatedElement element,
java.lang.annotation.Annotation annotation,
AnnotationAttributes attributes)
Post-process the result returned by the
AnnotatedElementUtils.Processor.process(java.lang.reflect.AnnotatedElement, java.lang.annotation.Annotation, int) method. |
AnnotationAttributes |
process(java.lang.reflect.AnnotatedElement annotatedElement,
java.lang.annotation.Annotation annotation,
int metaDepth)
Process the supplied annotation.
|
private final boolean classValuesAsString
private final boolean nestedAnnotationsAsMap
private final boolean aggregates
private final java.util.List<AnnotationAttributes> aggregatedResults
MergedAnnotationAttributesProcessor()
MergedAnnotationAttributesProcessor(boolean classValuesAsString, boolean nestedAnnotationsAsMap)
MergedAnnotationAttributesProcessor(boolean classValuesAsString, boolean nestedAnnotationsAsMap, boolean aggregates)
public boolean alwaysProcesses()
AnnotatedElementUtils.Processor
alwaysProcesses
in interface AnnotatedElementUtils.Processor<AnnotationAttributes>
true
if this processor always processes annotationspublic boolean aggregates()
AnnotatedElementUtils.Processor
AnnotatedElementUtils.Processor.process(java.lang.reflect.AnnotatedElement, java.lang.annotation.Annotation, int)
.
If this method returns true
, then AnnotatedElementUtils.Processor.getAggregatedResults()
must return a non-null value.
aggregates
in interface AnnotatedElementUtils.Processor<AnnotationAttributes>
true
if this processor supports aggregated resultsAnnotatedElementUtils.Processor.getAggregatedResults()
public java.util.List<AnnotationAttributes> getAggregatedResults()
AnnotatedElementUtils.Processor
NOTE: the processor does not aggregate the results
itself. Rather, the search algorithm that uses this processor is
responsible for asking this processor if it AnnotatedElementUtils.Processor.aggregates()
results
and then adding the post-processed results to the list returned by this
method.
getAggregatedResults
in interface AnnotatedElementUtils.Processor<AnnotationAttributes>
null
)AnnotatedElementUtils.Processor.aggregates()
public AnnotationAttributes process(java.lang.reflect.AnnotatedElement annotatedElement, java.lang.annotation.Annotation annotation, int metaDepth)
AnnotatedElementUtils.Processor
The supplied annotation will be an actual target annotation
that has been found by the search algorithm, unless this processor
is configured to always process
annotations in which case it may be some other annotation within an
annotation hierarchy. In the latter case, the metaDepth
will 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.
process
in interface AnnotatedElementUtils.Processor<AnnotationAttributes>
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 annotationspublic void postProcess(java.lang.reflect.AnnotatedElement element, java.lang.annotation.Annotation annotation, AnnotationAttributes attributes)
AnnotatedElementUtils.Processor
AnnotatedElementUtils.Processor.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 AnnotatedElementUtils.Processor.process(java.lang.reflect.AnnotatedElement, java.lang.annotation.Annotation, int)
that returned a non-null value.
postProcess
in interface AnnotatedElementUtils.Processor<AnnotationAttributes>
element
- the element that is annotated with the
supplied annotation, used for contextual logging; may be
null
if unknownannotation
- the annotation to post-processattributes
- the result to post-processprivate void overrideAttributes(java.lang.reflect.AnnotatedElement element, java.lang.annotation.Annotation annotation, AnnotationAttributes attributes, java.lang.String sourceAttributeName, java.util.List<java.lang.String> targetAttributeNames)
private void overrideAttribute(java.lang.reflect.AnnotatedElement element, java.lang.annotation.Annotation annotation, AnnotationAttributes attributes, java.lang.String sourceAttributeName, java.lang.String targetAttributeName)
private java.lang.Object getAdaptedValue(java.lang.reflect.AnnotatedElement element, java.lang.annotation.Annotation annotation, java.lang.String sourceAttributeName)