Class AnnotationValue<A extends Annotation>
- Type Parameters:
A- The annotation type
- All Implemented Interfaces:
AnnotationValueResolver, ValueResolver<CharSequence>
- Direct Known Subclasses:
EvaluatedAnnotationValue
This class implements the AnnotationValueResolver interface and methods such as ValueResolver.get(CharSequence, Class) can be used to retrieve the values of annotation members.
If a member is not present then the methods of the class will attempt to resolve the default value for a given annotation member. In this sense the behaviour of this class is similar to how
a implementation of Annotation behaves.
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Constructor Summary
ConstructorsConstructorDescriptionAnnotationValue(AnnotationValue<A> target, @Nullable Map<CharSequence, Object> defaultValues, ConvertibleValues<Object> convertibleValues, @Nullable Function<Object, Object> valueMapper) AnnotationValue(String annotationName) AnnotationValue(String annotationName, ConvertibleValues<Object> convertibleValues) AnnotationValue(String annotationName, Map<CharSequence, Object> values) AnnotationValue(String annotationName, Map<CharSequence, Object> values, AnnotationDefaultValuesProvider defaultValuesProvider) AnnotationValue(String annotationName, Map<CharSequence, Object> values, RetentionPolicy retentionPolicy) AnnotationValue(String annotationName, Map<CharSequence, Object> values, RetentionPolicy retentionPolicy, List<AnnotationValue<?>> stereotypes) AnnotationValue(String annotationName, Map<CharSequence, Object> values, @Nullable Map<CharSequence, Object> defaultValues) AnnotationValue(String annotationName, Map<CharSequence, Object> values, @Nullable Map<CharSequence, Object> defaultValues, @Nullable RetentionPolicy retentionPolicy) AnnotationValue(String annotationName, Map<CharSequence, Object> values, @Nullable Map<CharSequence, Object> defaultValues, @Nullable RetentionPolicy retentionPolicy, @Nullable List<AnnotationValue<?>> stereotypes) AnnotationValue(String annotationName, Map<CharSequence, Object> values, @Nullable Map<CharSequence, Object> defaultValues, @Nullable RetentionPolicy retentionPolicy, @Nullable List<AnnotationValue<?>> stereotypes, @Nullable AnnotationDefaultValuesProvider defaultValuesProvider) -
Method Summary
Modifier and TypeMethodDescriptionannotationClassValue(String member) TheAnnotationClassValueinstance for the given member.AnnotationClassValue<?>[]annotationClassValues(String member) TheAnnotationClassValueinstances for the given member.booleanValue(String member) The boolean value of the given member.booleanValue(String member, @Nullable Function<Object, Object> valueMapper) The boolean value of the given member.boolean[]booleanValues(String member) The boolean[] value for the given member.static <T extends Annotation>
AnnotationValueBuilder<T> builder(AnnotationValue<T> annotation) Start building a new annotation existing value.static <T extends Annotation>
AnnotationValueBuilder<T> builder(AnnotationValue<T> annotation, @Nullable RetentionPolicy retentionPolicy) Start building a new annotation existing value and retention policy.static <T extends Annotation>
AnnotationValueBuilder<T> Start building a new annotation for the given name.static <T extends Annotation>
AnnotationValueBuilder<T> Start building a new annotation for the given name.static <T extends Annotation>
AnnotationValueBuilder<T> builder(String annotationName, RetentionPolicy retentionPolicy) Start building a new annotation for the given name.The byte value of the given member.byte[]byteValues(String member) The byte[] value for the given member.The char value of the given member.char[]charValues(String member) The char[] value for the given member.The value of the annotation as a Class.classValue(String member) The value of the given annotation member as a Class.classValue(String member, Class<T> requiredType) The value of the given annotation member as a Class.classValue(String member, @Nullable Function<Object, Object> valueMapper) The value of the given annotation member as a Class.Class<?>[]classValues(String member) The value of the given annotation member as a Class.final booleanWhether a particular member is present.The double value of the given member.doubleValue(String member) The double value of the given member.doubleValue(String member, @Nullable Function<Object, Object> valueMapper) The double value of the given member.double[]doubleValues(String member) The double[] value for the given member.Return the enum value of the given member of the given enum type.Return the enum value of the given member of the given enum type.<E extends Enum>
E[]enumValues(String member, Class<E> enumType) Return the enum values of the given member of the given enum type.booleanfloatValue(String member) The double value of the given member.floatValue(String member, @Nullable Function<Object, Object> valueMapper) The double value of the given member.float[]floatValues(String member) The float[] value for the given member.<T> Optional<T> get(CharSequence member, ArgumentConversionContext<T> conversionContext) Resolve the given property for the given name.<T extends Annotation>
Optional<AnnotationValue<T>> getAnnotation(String member) Gets a list ofAnnotationValuefor the given member.<T extends Annotation>
Optional<AnnotationValue<T>> getAnnotation(String member, Class<T> type) Gets a list ofAnnotationValuefor the given member.final StringThe annotation name.<T extends Annotation>
List<AnnotationValue<T>> getAnnotations(String member) Gets a list ofAnnotationValuefor the given member.<T extends Annotation>
List<AnnotationValue<T>> getAnnotations(String member, Class<T> type) Gets a list ofAnnotationValuefor the given member.@Nullable Map<CharSequence, Object> The default values.final Set<CharSequence> Resolves the names of all the present annotation members.getProperties(String member) Resolves a map of properties for a member that is an array of annotations that have members called "name" or "key" to represent the key and "value" to represent the value.getProperties(String member, String keyMember) Resolve properties with a custom key member.final <T> TgetRequiredValue(Class<T> type) Get the value of thevaluemember of the annotation.final <T> TgetRequiredValue(String member, Class<T> type) Get the value of thevaluemember of the annotation.final RetentionPolicy@Nullable List<AnnotationValue<?>> The stereotypes of the annotation: the annotations it is meta-annotated with while it is being mapped or remapped, or theRetainableannotations it composes, retained in the reservedAnnotationUtil.STEREOTYPES_MEMBERmember with member overrides applied.<T> Optional<T> getValue(ArgumentConversionContext<T> conversionContext) Get the value of thevaluemember of the annotation.final <T> Optional<T> Get the value of thevaluemember of the annotation.final <T> Optional<T> Get the value of thevaluemember of the annotation.The attribute values.booleanIf this AnnotationValue contains Evaluated Expressions.inthashCode()intValue()The integer value of the given member.The integer value of the given member.The integer value of the given member.int[]The int[] value for the given member.booleanisFalse()booleanfinal booleanisPresent(CharSequence member) Is the given member present.booleanisTrue()booleanbooleanThe long value of the given member.The long value of the given member.long[]longValues(String member) The long[] value for the given member.booleanmatches(@Nullable AnnotationValue<?> other) Whether this and another annotation value are the same annotation.mutate()Creates a builder with the initial value of this annotation.static <T extends Annotation>
AnnotationValue<T> of(T annotation) Reads a live annotation instance as an annotation value.static Class<?> @Nullable []resolveClassValues(@Nullable Object value) The class values for the given value.static <E extends Enum>
E[]resolveEnumValues(Class<E> enumType, @Nullable Object rawValue) The enum values for the given enum type and raw value.static String[]resolveStringArray(String[] strs, @Nullable Function<Object, Object> valueMapper) The string[] values for the given value.static String @Nullable []resolveStringValues(@Nullable Object value, @Nullable Function<Object, @Nullable Object> valueMapper) The string values for the given value.shortValue(String member) The short value of the given member.shortValue(String member, @Nullable Function<Object, Object> valueMapper) The short value of the given member.short[]shortValues(String member) The short[] value for the given member.The double value of the given member.stringValue(String member) The string value of the given member.stringValue(String member, @Nullable Function<Object, Object> valueMapper) The string value of the given member.String[]stringValues(String member) The string values for the given member.String[]stringValues(String member, @Nullable Function<Object, Object> valueMapper) The string values for the given member and mapper.toString()Methods inherited from interface AnnotationValueResolver
booleanValue, booleanValues, byteValue, byteValues, charValue, charValues, classValues, doubleValues, enumValue, enumValues, enumValuesSet, floatValue, floatValues, intValues, longValue, longValues, shortValue, shortValues, stringValuesMethods inherited from interface ValueResolver
get, get, get
-
Constructor Details
-
AnnotationValue
- Parameters:
annotationName- The annotation namevalues- The values
-
AnnotationValue
@Internal public AnnotationValue(String annotationName, Map<CharSequence, Object> values, RetentionPolicy retentionPolicy) - Parameters:
annotationName- The annotation namevalues- The valuesretentionPolicy- The retention policy
-
AnnotationValue
@Internal public AnnotationValue(String annotationName, Map<CharSequence, Object> values, RetentionPolicy retentionPolicy, List<AnnotationValue<?>> stereotypes) - Parameters:
annotationName- The annotation namevalues- The valuesretentionPolicy- The retention policystereotypes- The stereotypes of the annotation
-
AnnotationValue
@Internal public AnnotationValue(String annotationName, Map<CharSequence, Object> values, @Nullable Map<CharSequence, Object> defaultValues) - Parameters:
annotationName- The annotation namevalues- The valuesdefaultValues- The default values
-
AnnotationValue
@Internal public AnnotationValue(String annotationName, Map<CharSequence, Object> values, AnnotationDefaultValuesProvider defaultValuesProvider) - Parameters:
annotationName- The annotation namevalues- The valuesdefaultValuesProvider- The default values provider- Since:
- 4.2.0
-
AnnotationValue
@Internal public AnnotationValue(String annotationName, Map<CharSequence, Object> values, @Nullable Map<CharSequence, Object> defaultValues, @Nullable RetentionPolicy retentionPolicy) - Parameters:
annotationName- The annotation namevalues- The valuesdefaultValues- The default valuesretentionPolicy- The retention policy
-
AnnotationValue
@Internal public AnnotationValue(String annotationName, Map<CharSequence, Object> values, @Nullable Map<CharSequence, Object> defaultValues, @Nullable RetentionPolicy retentionPolicy, @Nullable List<AnnotationValue<?>> stereotypes) - Parameters:
annotationName- The annotation namevalues- The valuesdefaultValues- The default valuesretentionPolicy- The retention policystereotypes- The stereotypes of the annotation
-
AnnotationValue
@Internal public AnnotationValue(String annotationName, Map<CharSequence, Object> values, @Nullable Map<CharSequence, Object> defaultValues, @Nullable RetentionPolicy retentionPolicy, @Nullable List<AnnotationValue<?>> stereotypes, @Nullable AnnotationDefaultValuesProvider defaultValuesProvider) - Parameters:
annotationName- The annotation namevalues- The valuesdefaultValues- The default valuesretentionPolicy- The retention policystereotypes- The stereotypes of the annotationdefaultValuesProvider- The defaults values provider
-
AnnotationValue
-
AnnotationValue
@Internal public AnnotationValue(String annotationName, ConvertibleValues<Object> convertibleValues) - Parameters:
annotationName- The annotation nameconvertibleValues- The convertible values
-
AnnotationValue
@Internal public AnnotationValue(AnnotationValue<A> target, @Nullable Map<CharSequence, Object> defaultValues, ConvertibleValues<Object> convertibleValues, @Nullable Function<Object, Object> valueMapper) - Parameters:
target- The targetdefaultValues- The default valuesconvertibleValues- The convertible valuesvalueMapper- The value mapper
-
-
Method Details
-
getValueMapper
-
mutate
Creates a builder with the initial value of this annotation.- Returns:
- The builder with this annotation value
- Since:
- 4.0.0
-
getRetentionPolicy
- Returns:
- The retention policy.
-
getStereotypes
The stereotypes of the annotation: the annotations it is meta-annotated with while it is being mapped or remapped, or theRetainableannotations it composes, retained in the reservedAnnotationUtil.STEREOTYPES_MEMBERmember with member overrides applied.- Returns:
- The stereotypes of the annotation, or
nullif they are not known
-
getDefaultValues
The default values.- Returns:
- The default of the annotation or null if not specified.
- Since:
- 4.0.0
-
getProperties
Resolves a map of properties for a member that is an array of annotations that have members called "name" or "key" to represent the key and "value" to represent the value.For example consider the following annotation definition:
@PropertySource({ @Property(name = "one", value = "1"), @Property(name = "two", value = "2")}) public class MyBean { ... }You can use this method to resolve the values of the
PropertySourceannotation such that the following assertion is true:annotationValue.getProperties("value") == [one:1, two:2]- Parameters:
member- The member- Returns:
- The properties as an immutable map.
-
getProperties
-
enumValue
Return the enum value of the given member of the given enum type.- Specified by:
enumValuein interfaceAnnotationValueResolver- Type Parameters:
E- The enum type- Parameters:
member- The annotation memberenumType- The required type- Returns:
- An
Optionalof the enum value
-
enumValue
public <E extends Enum> Optional<E> enumValue(String member, Class<E> enumType, @Nullable Function<Object, Object> valueMapper) Return the enum value of the given member of the given enum type.- Type Parameters:
E- The enum type- Parameters:
member- The annotation memberenumType- The required typevalueMapper- The value mapper- Returns:
- An
Optionalof the enum value
-
enumValues
Return the enum values of the given member of the given enum type.- Specified by:
enumValuesin interfaceAnnotationValueResolver- Type Parameters:
E- The enum type- Parameters:
member- The annotation memberenumType- The required type- Returns:
- An array of enum values
-
classValue
The value of the annotation as a Class.- Specified by:
classValuein interfaceAnnotationValueResolver- Returns:
- An
Optionalclass
-
classValue
The value of the given annotation member as a Class.- Specified by:
classValuein interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An
Optionalclass
-
classValue
The value of the given annotation member as a Class.- Specified by:
classValuein interfaceAnnotationValueResolver- Type Parameters:
T- The required type- Parameters:
member- The annotation memberrequiredType- The required type- Returns:
- An
Optionalclass
-
classValue
-
stringValues
Description copied from interface:AnnotationValueResolverThe string values for the given member.- Specified by:
stringValuesin interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An array of
String
-
booleanValues
Description copied from interface:AnnotationValueResolverThe boolean[] value for the given member.- Specified by:
booleanValuesin interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An array of
boolean
-
byteValues
Description copied from interface:AnnotationValueResolverThe byte[] value for the given member.- Specified by:
byteValuesin interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An array of
byte
-
charValues
Description copied from interface:AnnotationValueResolverThe char[] value for the given member.- Specified by:
charValuesin interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An array of
char
-
intValues
Description copied from interface:AnnotationValueResolverThe int[] value for the given member.- Specified by:
intValuesin interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An array of
int
-
doubleValues
Description copied from interface:AnnotationValueResolverThe double[] value for the given member.- Specified by:
doubleValuesin interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An array of
double
-
longValues
Description copied from interface:AnnotationValueResolverThe long[] value for the given member.- Specified by:
longValuesin interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An array of
long
-
floatValues
Description copied from interface:AnnotationValueResolverThe float[] value for the given member.- Specified by:
floatValuesin interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An array of
float
-
shortValues
Description copied from interface:AnnotationValueResolverThe short[] value for the given member.- Specified by:
shortValuesin interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An array of
short
-
stringValues
-
classValues
Description copied from interface:AnnotationValueResolverThe value of the given annotation member as a Class.- Specified by:
classValuesin interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An array of classes
-
annotationClassValues
Description copied from interface:AnnotationValueResolverTheAnnotationClassValueinstances for the given member. UnlikeAnnotationValueResolver.classValues(String)this may include classes that are no the classpath.- Specified by:
annotationClassValuesin interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An array of class values
-
annotationClassValue
Description copied from interface:AnnotationValueResolverTheAnnotationClassValueinstance for the given member.- Specified by:
annotationClassValuein interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An annotation class value
-
intValue
The integer value of the given member.- Specified by:
intValuein interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An
OptionalInt
-
intValue
The integer value of the given member.- Parameters:
member- The annotation membervalueMapper- The value mapper- Returns:
- An
OptionalInt
-
byteValue
Description copied from interface:AnnotationValueResolverThe byte value of the given member.- Specified by:
byteValuein interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An
OptionalofByte
-
charValue
Description copied from interface:AnnotationValueResolverThe char value of the given member.- Specified by:
charValuein interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An
OptionalofCharacter
-
intValue
The integer value of the given member.- Specified by:
intValuein interfaceAnnotationValueResolver- Returns:
- An
OptionalInt
-
longValue
Description copied from interface:AnnotationValueResolverThe long value of the given member.- Specified by:
longValuein interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An
OptionalLong
-
longValue
The long value of the given member.- Parameters:
member- The annotation membervalueMapper- The value mapper- Returns:
- An
OptionalLong
-
shortValue
Description copied from interface:AnnotationValueResolverThe short value of the given member.- Specified by:
shortValuein interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An
OptionalofShort
-
shortValue
-
booleanValue
-
doubleValue
The double value of the given member.- Specified by:
doubleValuein interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An
OptionalDouble
-
doubleValue
The double value of the given member.- Parameters:
member- The annotation membervalueMapper- The value mapper- Returns:
- An
OptionalDouble
-
floatValue
Description copied from interface:AnnotationValueResolverThe double value of the given member.- Specified by:
floatValuein interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An
OptionalDouble
-
floatValue
-
doubleValue
The double value of the given member.- Specified by:
doubleValuein interfaceAnnotationValueResolver- Returns:
- An
OptionalDouble
-
stringValue
The string value of the given member.- Specified by:
stringValuein interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An
OptionalInt
-
stringValue
-
stringValue
The double value of the given member.- Specified by:
stringValuein interfaceAnnotationValueResolver- Returns:
- An
OptionalInt
-
booleanValue
Description copied from interface:AnnotationValueResolverThe boolean value of the given member.- Specified by:
booleanValuein interfaceAnnotationValueResolver- Parameters:
member- The annotation member- Returns:
- An
Optionalboolean
-
isPresent
Is the given member present.- Specified by:
isPresentin interfaceAnnotationValueResolver- Parameters:
member- The member- Returns:
- True if it is
-
isTrue
public boolean isTrue()- Specified by:
isTruein interfaceAnnotationValueResolver- Returns:
- Is the value of the annotation true.
-
isTrue
- Specified by:
isTruein interfaceAnnotationValueResolver- Parameters:
member- The member- Returns:
- Is the value of the annotation true.
-
isTrue
-
isFalse
public boolean isFalse()- Specified by:
isFalsein interfaceAnnotationValueResolver- Returns:
- Is the value of the annotation true.
-
isFalse
- Specified by:
isFalsein interfaceAnnotationValueResolver- Parameters:
member- The member- Returns:
- Is the value of the annotation true.
-
getAnnotationName
-
contains
Whether a particular member is present.- Parameters:
member- The member- Returns:
- True if it is
-
getMemberNames
Resolves the names of all the present annotation members.- Returns:
- The names of the members
-
getValues
The attribute values. The reservedAnnotationUtil.STEREOTYPES_MEMBERmember is not an attribute and is not included; it is read throughgetStereotypes().- Specified by:
getValuesin interfaceAnnotationValueResolver- Returns:
- The attribute values
-
getConvertibleValues
- Returns:
- The convertible values
-
get
Description copied from interface:ValueResolverResolve the given property for the given name.- Specified by:
getin interfaceValueResolver<A extends Annotation>- Type Parameters:
T- The concrete type- Parameters:
member- The nameconversionContext- The conversion context- Returns:
- An optional containing the property value if it exists and is able to be converted
-
getValue
Get the value of thevaluemember of the annotation.- Type Parameters:
T- The type- Parameters:
conversionContext- The conversion context- Returns:
- The result
-
getValue
-
getValue
-
getRequiredValue
Get the value of thevaluemember of the annotation.- Type Parameters:
T- The type- Parameters:
type- The type- Returns:
- The result
- Throws:
IllegalStateException- If no member is available that conforms to the given type
-
getRequiredValue
Get the value of thevaluemember of the annotation.- Type Parameters:
T- The type- Parameters:
member- The membertype- The type- Returns:
- The result
- Throws:
IllegalStateException- If no member is available that conforms to the given name and type
-
getAnnotations
Gets a list ofAnnotationValuefor the given member.- Type Parameters:
T- The type- Parameters:
member- The membertype- The type- Returns:
- The result
- Throws:
IllegalStateException- If no member is available that conforms to the given name and type
-
getAnnotations
Gets a list ofAnnotationValuefor the given member.- Type Parameters:
T- The type- Parameters:
member- The member- Returns:
- The result
- Throws:
IllegalStateException- If no member is available that conforms to the given name and type
-
getAnnotation
public <T extends Annotation> Optional<AnnotationValue<T>> getAnnotation(String member, Class<T> type) Gets a list ofAnnotationValuefor the given member.- Type Parameters:
T- The type- Parameters:
member- The membertype- The type- Returns:
- The result
- Throws:
IllegalStateException- If no member is available that conforms to the given name and type
-
getAnnotation
Gets a list ofAnnotationValuefor the given member.- Type Parameters:
T- The type- Parameters:
member- The member- Returns:
- The result
- Throws:
IllegalStateException- If no member is available that conforms to the given name and type- Since:
- 3.3.0
-
hasEvaluatedExpressions
public boolean hasEvaluatedExpressions()If this AnnotationValue contains Evaluated Expressions.- Returns:
- true if it is
- Since:
- 4.0.0
-
toString
-
matches
Whether this and another annotation value are the same annotation.Two values are the same annotation when they name the same annotation and bind the same members to the same values, with the members neither of them declared filled in from the defaults of the annotation. An element which leaves a member at its default therefore matches one which writes that default down, which
equals(Object)does not do: it compares the members that were declared.This is a comparison of every member, where
equals(Object)passes over a member the other value does not have. A member can only be left out when it has a default, so filling the defaults in is what makes every member comparable.- Parameters:
other- The other annotation value- Returns:
- Whether the two are the same annotation
- Since:
- 5.2.0
-
hashCode
-
equals
-
builder
Start building a new annotation for the given name.- Type Parameters:
T- The annotation type- Parameters:
annotationName- The annotation name- Returns:
- The builder
-
builder
public static <T extends Annotation> AnnotationValueBuilder<T> builder(String annotationName, RetentionPolicy retentionPolicy) Start building a new annotation for the given name.- Type Parameters:
T- The annotation type- Parameters:
annotationName- The annotation nameretentionPolicy- The retention policy- Returns:
- The builder
- Since:
- 2.4.0
-
builder
Start building a new annotation for the given name.- Type Parameters:
T- The annotation type- Parameters:
annotation- The annotation name- Returns:
- The builder
-
builder
public static <T extends Annotation> AnnotationValueBuilder<T> builder(AnnotationValue<T> annotation) Start building a new annotation existing value.- Type Parameters:
T- The annotation type- Parameters:
annotation- The annotation name- Returns:
- The builder
- Since:
- 4.0.0
-
builder
public static <T extends Annotation> AnnotationValueBuilder<T> builder(AnnotationValue<T> annotation, @Nullable RetentionPolicy retentionPolicy) Start building a new annotation existing value and retention policy.- Type Parameters:
T- The annotation type- Parameters:
annotation- The annotation nameretentionPolicy- The retention policy. Defaults to runtime.- Returns:
- The builder
-
of
Reads a live annotation instance as an annotation value.Code handed annotation instances at runtime, such as a qualifier passed to a bean lookup, needs them in the form compiled metadata records them so that the two compare equal. Every zero-argument member of the annotation is read, the ones left at their default included since an instance answers every one of its members, and converted the way an annotation processor records it:
- a
Classbecomes anAnnotationClassValue - an
Enumbecomes the name of its constant - a nested
Annotationbecomes anAnnotationValueof every one of its members, recursively - an array of any of the above becomes an array of the converted form
- any other value, such as a primitive, a
Stringor an array of either, is kept as it is
No member is left out. Whether a member takes part in the comparison of two qualifiers is a concern of the qualifier rather than of the conversion, so
@NonBindingis not applied here.- Type Parameters:
T- The annotation type- Parameters:
annotation- The annotation instance- Returns:
- The annotation value, with
RetentionPolicy.RUNTIMEretention - Throws:
IllegalStateException- When a member cannot be read, because the annotation type is not open to this module or because the instance does not answer for it- Since:
- 5.2.0
- a
-
resolveStringValues
-
resolveEnumValues
@Internal public static <E extends Enum> E[] resolveEnumValues(Class<E> enumType, @Nullable Object rawValue) The enum values for the given enum type and raw value.- Type Parameters:
E- The enum generic type- Parameters:
enumType- The enum typerawValue- The raw value- Returns:
- An array of enum values
-
resolveStringArray
-
resolveClassValues
-