Interface AnnotationInfo
Type for annotation instances.
Targeting notes:
Annotations may be attached to packages, to classes, to fields, to methods, and to method parameters.
Particular rules are used to associate annotations to entities in addition to the declaring entity. There are particular rules for inherited methods and fields, particular rules for class and method annotations marked with the inherited meta-annotations, and particular rules for class annotations which have application to methods and fields.
A method or a field annotation not only applies to the method or field which declares the annotation, in the class which declares the method or field, but also apply to the method or field in any subclass which inherites the method or field, but which does not provide a new implementation.
A class annotation which has the inherited meta-annotation not only applies to the class which declared that annotation, but also applies to subclasses of that declaring class. A method annotation which has the inherited meta-annotation not only applies to the method in the class which declares the method and the annotation, but applies as well to the method in any subclasses of the declaring class.
A class annotation which is specified to target fields (or methods), and which is declared on a class has applications to declared fields (or declared methods) of the declaring class. The general rule is to apply the class annotation to declared fields (or declared methods). There are special cases where the general rule is modified to limit application to specific fields (or methods).
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Naming constant: The qualified name ofjava.lang.annotation.Annotation
.static final String
Naming constant: The prefix for thejava.lang.annotation
package, (with a trailing ".").static final String
Text for the class name of theinherited
meta-annotation. -
Method Summary
Modifier and TypeMethodDescriptionAnswer the class of the annotation type of this annotation instance.Answer the fully qualified name of the annotation class of this annotation occurrence.getAnnotationValue
(String name) Answer a member value of this annotation as an annotation.List<? extends AnnotationValue>
getArrayValue
(String name) Answer a member value of this annotation as an array.getBoolean
(String name) Answer a member value of this annotation as a boolean object.boolean
getBooleanValue
(String name) Answer a member value of this annotation as a boolean value.Answer a member value of this annotation as a byte object.byte
getByteValue
(String name) Answer a member value of this annotation as a byte value.Retrieves a named value associated with this AnnotationInfo object.getCharacter
(String name) Answer a member value of this annotation as a character object.char
getCharValue
(String name) Answer a member value of this annotation as a char value.getClassNameValue
(String name) Answer a member value of this annotation as a class name (for a class reference value).Answer a member value of this annotation as a double object.double
getDoubleValue
(String name) Answer a member value of this annotation as a simple double (double precision floating point) value.getEnumClassName
(String name) Answer the name of the class of a stored enumerated member value.getEnumValue
(String name) Answer the name of a stored enumerated member value.Answer a print string for the receiver, for use in debugging.Answer the store which holds this info object.Retrieves a named value associated with this AnnotationInfo object.boolean
Tell if this annotation has theinherited
meta-annotation.boolean
isValueDefaulted
(String name) Tell if the named child value was assigned using the default value from the annotation class.
-
Field Details
-
JAVA_LANG_ANNOTATION_CLASS_PREFIX
Naming constant: The prefix for the
java.lang.annotation
package, (with a trailing ".").- See Also:
-
JAVA_LANG_ANNOTATION_INHERITED
Text for the class name of the
inherited
meta-annotation.- See Also:
-
ANNOTATION_CLASS_NAME
Naming constant: The qualified name of
java.lang.annotation.Annotation
.- See Also:
-
-
Method Details
-
getHashText
String getHashText()Answer a print string for the receiver, for use in debugging. The value is guaranteed to be unique during the lifetime of the receiver, and, for frequently created types, will be created on demand.
- Returns:
- A print string for the receiver.
-
getInfoStore
InfoStore getInfoStore()Answer the store which holds this info object.
- Returns:
- The store which holds this info object.
-
getAnnotationClassName
String getAnnotationClassName()Answer the fully qualified name of the annotation class of this annotation occurrence.
- Returns:
- The fully qualified name of the annotation class of this annotation occurrence.
- See Also:
-
getAnnotationClassInfo
ClassInfo getAnnotationClassInfo()Answer the class of the annotation type of this annotation instance.
If attached to a class, the result is very much not that class. If attached to a method or field, this is not the class of the method or field.
- Returns:
- The class info for the annotation type of this annotation instance.
- See Also:
-
isInherited
boolean isInherited()Tell if this annotation has the
inherited
meta-annotation.- Returns:
- True if this annotation has the
inherited
meta-annotation. Otherwise, false. - See Also:
-
isValueDefaulted
Tell if the named child value was assigned using the default value from the annotation class.- Parameters:
name
- The name of the child value which is to be tested.- Returns:
- True if the child value was defaulted. Otherwise, false.
-
getValue
Retrieves a named value associated with this AnnotationInfo object.- Parameters:
name
- a String containing the named value to retrieve.- Returns:
- an AnnotationValue object containing the annotation value with the given name, or null if the value does not exist.
-
getCachedAnnotationValue
Retrieves a named value associated with this AnnotationInfo object. WITHOUT defaults processing. ALL CALLS SHOULD GO THROUGH getValue(String name) UNLESS a viable parent classloader is unavailable. In this case, resolution of classes of the form javax.annotation.etc... will not resolve, which may cause error messages or other exceptions. This returns ONLY the annotation values explicitly defined on the class, or null otherwise.- Parameters:
name
- a String containing the named value to retrieve.- Returns:
- an AnnotationValue object containing the annotation value with the given name, or null if the value does not exist.
-
getAnnotationValue
Answer a member value of this annotation as an annotation.
- Parameters:
name
- The name of the member value to retrieve.- Returns:
- A member value of this annotation as an annotation.
-
getArrayValue
Answer a member value of this annotation as an array.
- Parameters:
name
- The name of the member value to retrieve.- Returns:
- A member value of this annotation as an array.
-
getBoolean
Answer a member value of this annotation as a boolean object.
Answer null if the named member is not available. Absent full defaulting support, valid members will return null if no user defined value was provided.
- Parameters:
name
- The name of the member value to retrieve.- Returns:
- A member value of this annotation as a boolean object.
-
getBooleanValue
Answer a member value of this annotation as a boolean value.
A
NullPointerException
will occur is the named value is not available.- Parameters:
name
- The name of the member value to retrieve.- Returns:
- A member value of this annotation as a boolean value.
-
getByte
Answer a member value of this annotation as a byte object.
Answer null if the named member is not available. Absent full defaulting support, valid members will return null if no user defined value was provided.
- Parameters:
name
- The name of the member value to retrieve.- Returns:
- A member value of this annotation as a byte object.
-
getByteValue
Answer a member value of this annotation as a byte value.
A
NullPointerException
will occur is the named value is not available.- Parameters:
name
- The name of the member value to retrieve.- Returns:
- A member value of this annotation as a byte value.
-
getCharacter
Answer a member value of this annotation as a character object.
Answer null if the named member is not available. Absent full defaulting support, valid members will return null if no user defined value was provided.
- Parameters:
name
- The name of the member value to retrieve.- Returns:
- A member value of this annotation as a character object.
-
getCharValue
Answer a member value of this annotation as a char value.
A
NullPointerException
will occur is the named value is not available.- Parameters:
name
- The name of the member value to retrieve.- Returns:
- A member value of this annotation as a char value.
-
getClassNameValue
Answer a member value of this annotation as a class name (for a class reference value).
- Parameters:
name
- The name of the member value to retrieve.- Returns:
- The member value as the class name of a class reference value.
-
getDouble
Answer a member value of this annotation as a double object.
Answer null if the named member is not available. Absent full defaulting support, valid members will return null if no user defined value was provided.
- Parameters:
name
- The name of the member value to retrieve.- Returns:
- A member value of this annotation a double object.
-
getDoubleValue
Answer a member value of this annotation as a simple double (double precision floating point) value.
A
NullPointerException
will occur is the named value is not available.- Parameters:
name
- The name of the member value to retrieve.- Returns:
- A member value of this annotation a double value.
-
getEnumClassName
Answer the name of the class of a stored enumerated member value.
Answer null if the named member is not available or has a null value. Absent full defaulting support, valid members will return null if no user defined value was provided.
- Parameters:
name
- The name of the member value to retrieve.- Returns:
- The name of the class of a stored enumerated member value.
- See Also:
-
getEnumValue
Answer the name of a stored enumerated member value.
Answer null if the named member is not available or has a null value. Absent full defaulting support, valid members will return null if no user defined value was provided.
- Parameters:
name
- The name of the member value to retrieve.- Returns:
- The name of a stored enumerated member value.
- See Also:
-