Interface ReflectionAnnotationCustomizer
ReflectionAnnotations builds reflectively.
A processor extension that derives a member from the annotation type - the validator classes a constraint
is validated by, copied from its @Constraint meta-annotation - has to be applied to the reflective
metadata too, or the code reading the member behaves differently for a type the processor never saw. An
implementation is registered as a service and receives every annotation the builder converts, stereotypes
included, with a mutable copy of its values.
- Since:
- 5.2.0
- Author:
- Denis Stepanov
-
Method Summary
Modifier and TypeMethodDescriptiondefault List<AnnotationValue<AliasFor>> voidcustomize(Annotation annotation, Map<CharSequence, Object> values) Customizes the values of an annotation before they enter the metadata.default booleanisRetainable(Class<? extends Annotation> annotationType) Whether an annotation type is to be treated asRetainable, so that every annotation composing it keeps the composed occurrence in its own retained tree.default booleansupports(Class<? extends Annotation> annotationType) Whether the customizer applies to an annotation type.
-
Method Details
-
supports
Whether the customizer applies to an annotation type.- Parameters:
annotationType- The annotation type- Returns:
- Whether
customize(Annotation, Map)is to be called for the annotations of the type
-
isRetainable
Whether an annotation type is to be treated asRetainable, so that every annotation composing it keeps the composed occurrence in its own retained tree.The compile-time counterpart is a remapper marking the contract of a family retainable - the validation processor marks
jakarta.validation.Constraint, so that a composed constraint keeps the constraints it composes. A specification whose contract is an annotation it does not own cannot annotate it, and says so here instead, so that the tree the reflective metadata carries is the tree the processors record.- Parameters:
annotationType- The annotation type- Returns:
- Whether the annotations composing the type retain it
-
aliasesOf
The member overrides a member of an annotation declares in terms other thanAliasFor, stated as theAliasForannotations a transformer would produce for it at compilation time.A specification declares an override in its own terms -
jakarta.validation.OverridesAttributenames the composed constraint and the member of it a member overrides - and the processors read it through a transformer mapping it ontoAliasFor. That transformer does not run at runtime, so the same mapping is stated here, and the retained tree carries the overridden members whichever way the metadata was built.- Parameters:
member- The member of an annotation type- Returns:
- The aliases the member declares, empty when it declares none in other terms
-
customize
Customizes the values of an annotation before they enter the metadata.- Parameters:
annotation- The annotationvalues- The values, asReflectionAnnotations.values(Annotation)converts them, to add to, replace or remove from
-