Interface ReflectionAnnotationCustomizer


@Indexed(ReflectionAnnotationCustomizer.class) public interface ReflectionAnnotationCustomizer
The runtime counterpart of the annotation mappers, transformers and remappers of the annotation processors, for the metadata 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 Type
    Method
    Description
    aliasesOf(Method member)
    The member overrides a member of an annotation declares in terms other than AliasFor, stated as the AliasFor annotations a transformer would produce for it at compilation time.
    void
    customize(Annotation annotation, Map<CharSequence, Object> values)
    Customizes the values of an annotation before they enter the metadata.
    default boolean
    isRetainable(Class<? extends Annotation> annotationType)
    Whether an annotation type is to be treated as Retainable, so that every annotation composing it keeps the composed occurrence in its own retained tree.
    default boolean
    supports(Class<? extends Annotation> annotationType)
    Whether the customizer applies to an annotation type.
  • Method Details

    • supports

      default boolean supports(Class<? extends Annotation> annotationType)
      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

      default boolean isRetainable(Class<? extends Annotation> annotationType)
      Whether an annotation type is to be treated as Retainable, 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

      default List<AnnotationValue<AliasFor>> aliasesOf(Method member)
      The member overrides a member of an annotation declares in terms other than AliasFor, stated as the AliasFor annotations a transformer would produce for it at compilation time.

      A specification declares an override in its own terms - jakarta.validation.OverridesAttribute names the composed constraint and the member of it a member overrides - and the processors read it through a transformer mapping it onto AliasFor. 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

      void customize(Annotation annotation, Map<CharSequence, Object> values)
      Customizes the values of an annotation before they enter the metadata.
      Parameters:
      annotation - The annotation
      values - The values, as ReflectionAnnotations.values(Annotation) converts them, to add to, replace or remove from