Class AnnotationInfo
- All Implemented Interfaces:
HasName
,Comparable<AnnotationInfo>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
InvocationHandler
for dynamically instantiating anAnnotation
object. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AnnotationParameterValueList
The annotation param values.private boolean
Set to true once any Object[] arrays of boxed types in annotationParamValues have been lazily converted to primitive arrays.private AnnotationParameterValueList
The annotation param values with defaults.private String
The name.Fields inherited from class io.github.classgraph.ScanResultObject
classRef, scanResult
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for deserialization.AnnotationInfo
(String name, AnnotationParameterValueList annotationParamValues) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionint
(package private) void
Convert wrapper arrays to primitive arrays.boolean
protected void
findReferencedClassInfo
(Map<String, ClassInfo> classNameToClassInfo, Set<ClassInfo> refdClassInfo, LogNode log) GetClassInfo
objects for any classes referenced in the type descriptor or type signature.Return theClassInfo
object for the annotation class.protected String
Get the name of the annotation class, forgetClassInfo()
.Get the default parameter values.getName()
Get the name.Get the parameter values.getParameterValues
(boolean includeDefaultValues) Get the parameter values.int
hashCode()
boolean
Checks if the annotation is inherited.Load theAnnotation
class corresponding to thisAnnotationInfo
object, by callinggetClassInfo().loadClass()
, then create a new instance of the annotation, with the annotation parameter values obtained from thisAnnotationInfo
object, possibly overriding default annotation parameter values obtained from callinggetClassInfo()
thenClassInfo.getAnnotationDefaultParameterValues()
.(package private) void
setScanResult
(ScanResult scanResult) Set ScanResult backreferences in info objects after scan has completed.protected void
toString
(boolean useSimpleNames, StringBuilder buf) Render to string.Methods inherited from class io.github.classgraph.ScanResultObject
findReferencedClassInfo, loadClass, loadClass, loadClass, loadClass, toString, toString, toStringWithSimpleNames
-
Field Details
-
name
The name. -
annotationParamValues
The annotation param values. -
annotationParamValuesHasBeenConvertedToPrimitive
private transient boolean annotationParamValuesHasBeenConvertedToPrimitiveSet to true once any Object[] arrays of boxed types in annotationParamValues have been lazily converted to primitive arrays. -
annotationParamValuesWithDefaults
The annotation param values with defaults.
-
-
Constructor Details
-
AnnotationInfo
AnnotationInfo()Default constructor for deserialization. -
AnnotationInfo
AnnotationInfo(String name, AnnotationParameterValueList annotationParamValues) Constructor.- Parameters:
name
- The name of the annotation.annotationParamValues
- The annotation parameter values, or null if none.
-
-
Method Details
-
getName
Get the name. -
isInherited
public boolean isInherited()Checks if the annotation is inherited.- Returns:
- true if this annotation is meta-annotated with
Inherited
.
-
getDefaultParameterValues
Get the default parameter values.- Returns:
- the list of default parameter values for this annotation, or the empty list if none.
-
getParameterValues
Get the parameter values.- Parameters:
includeDefaultValues
- if true, include default values for any annotation parameter value that is missing.- Returns:
- The parameter values of this annotation, including any default parameter values inherited from the annotation class definition (if requested), or the empty list if none.
-
getParameterValues
Get the parameter values.- Returns:
- The parameter values of this annotation, including any default parameter values inherited from the annotation class definition, or the empty list if none.
-
getClassName
Get the name of the annotation class, forgetClassInfo()
.- Specified by:
getClassName
in classScanResultObject
- Returns:
- the class name
-
setScanResult
Description copied from class:ScanResultObject
Set ScanResult backreferences in info objects after scan has completed.- Overrides:
setScanResult
in classScanResultObject
- Parameters:
scanResult
- the scan result
-
findReferencedClassInfo
protected void findReferencedClassInfo(Map<String, ClassInfo> classNameToClassInfo, Set<ClassInfo> refdClassInfo, LogNode log) GetClassInfo
objects for any classes referenced in the type descriptor or type signature.- Overrides:
findReferencedClassInfo
in classScanResultObject
- Parameters:
classNameToClassInfo
- the map from class name toClassInfo
.refdClassInfo
- the referenced class infolog
- the log
-
getClassInfo
Return theClassInfo
object for the annotation class.- Overrides:
getClassInfo
in classScanResultObject
- Returns:
- The
ClassInfo
object for the referenced class.
-
loadClassAndInstantiate
Load theAnnotation
class corresponding to thisAnnotationInfo
object, by callinggetClassInfo().loadClass()
, then create a new instance of the annotation, with the annotation parameter values obtained from thisAnnotationInfo
object, possibly overriding default annotation parameter values obtained from callinggetClassInfo()
thenClassInfo.getAnnotationDefaultParameterValues()
.Note that the returned
Annotation
will have some sort ofInvocationHandler
proxy type, such asio.github.classgraph.features.$Proxy4
orcom.sun.proxy.$Proxy6
. This is an unavoidable side effect of the fact that concreteAnnotation
instances cannot be instantiated directly. (ClassGraph uses the same approach that the JDK uses to instantiate annotations from a map.) However, proxy instances are handled specially when it comes to casting andinstanceof
: you are able to cast the returned proxy instance to the annotation type, andinstanceof
checks against the annotation class will succeed.Of course another option you have for getting the concrete annotations, rather than instantiating the annotations on a
ClassInfo
object via this method, is to callClassInfo.loadClass()
, and read the annotations directly from the returnedClass
object.- Returns:
- The new
Annotation
instance, as a dynamic proxy object that can be cast to the expected annotation type.
-
convertWrapperArraysToPrimitiveArrays
void convertWrapperArraysToPrimitiveArrays()Convert wrapper arrays to primitive arrays. -
compareTo
- Specified by:
compareTo
in interfaceComparable<AnnotationInfo>
-
equals
-
hashCode
public int hashCode() -
toString
Description copied from class:ScanResultObject
Render to string.- Specified by:
toString
in classScanResultObject
- Parameters:
useSimpleNames
- if true, use just the simple name of each class.buf
- the buf
-