Class AnnotationDefaults
AnnotationMetadataSupport.getDefaultValues(String) answers from a registry keyed by annotation
name, which generated code fills in as classes load. That registry serves the accessors of metadata built at
compilation time, where the defaults are written into the generated class; it is the wrong source for anything
that has the annotation type in hand, for two reasons. It is mutable and filled in over the life of the
process, so the same question can be answered differently depending on what has been loaded, and it is keyed
by name, so the same annotation name defined by two class loaders resolves to whichever was registered last.
What is read here is a property of the type alone: the Method.getDefaultValue() of each of its
members, converted into the shapes the metadata records values in. A ClassValue keys it by the class
rather than the name, so two deployments of the same annotation name keep their own defaults, and nothing
outside can change what a type answers.
- Since:
- 5.2.0
- Author:
- Denis Stepanov
-
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectA member value as the metadata records it: a class as anAnnotationClassValue, an enum by the name of its constant and a nested annotation as anAnnotationValue, arrays of each likewise.membersOf(Class<? extends Annotation> annotationType) The members of an annotation type, made accessible - the type may not be public - and ordered by name.static Map<CharSequence, Object> of(Class<? extends Annotation> annotationType) The defaults of an annotation type, in the shapes the metadata records values in.
-
Method Details
-
membersOf
The members of an annotation type, made accessible - the type may not be public - and ordered by name.- Parameters:
annotationType- The annotation type- Returns:
- The members, unmodifiable
-
of
The defaults of an annotation type, in the shapes the metadata records values in.- Parameters:
annotationType- The annotation type- Returns:
- The defaults by member name, unmodifiable and never null
-
convert
A member value as the metadata records it: a class as anAnnotationClassValue, an enum by the name of its constant and a nested annotation as anAnnotationValue, arrays of each likewise.- Parameters:
value- The value read off the annotation type- Returns:
- The recorded form
-