Class AnnotationParameterValue
java.lang.Object
io.github.classgraph.ScanResultObject
io.github.classgraph.AnnotationParameterValue
- All Implemented Interfaces:
HasName, Comparable<AnnotationParameterValue>
public class AnnotationParameterValue
extends ScanResultObject
implements HasName, Comparable<AnnotationParameterValue>
A wrapper used to pair annotation parameter names with annotation parameter values.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringThe the parameter name.private ObjectTypedValueWrapperThe parameter value.Fields inherited from class ScanResultObject
classRef, scanResult -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for deserialization.AnnotationParameterValue(String name, Object value) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionint(package private) voidconvertWrapperArraysToPrimitiveArrays(ClassInfo annotationClassInfo) For primitive array type params, replace Object[] arrays containing boxed types with primitive arrays (need to check the type of each method of the annotation class to determine if it is a primitive array type).booleanprotected voidfindReferencedClassInfo(Map<String, ClassInfo> classNameToClassInfo, Set<ClassInfo> refdClassInfo, LogNode log) GetClassInfoobjects for any classes referenced in the annotation parameters.protected ClassInfoGet theClassInfoobject for the referenced class, or null if the referenced class was not encountered during scanning (i.e.protected StringThe name of the class (used byScanResultObject.getClassInfo()to fetch theClassInfoobject for the class).getName()Get the annotation parameter name.getValue()Get the annotation parameter value.inthashCode()(package private) Objectinstantiate(ClassInfo annotationClassInfo) Instantiate an annotation parameter value.(package private) voidsetScanResult(ScanResult scanResult) Set ScanResult backreferences in info objects after scan has completed.(package private) voidSet (update) the value of the annotation parameter.protected voidtoString(boolean useSimpleNames, StringBuilder buf) Render to string.private static voidtoString(Object val, boolean useSimpleNames, StringBuilder buf) Write an annotation parameter value's string representation to the buffer.private StringTo string, param value only.(package private) voidtoStringParamValueOnly(boolean useSimpleNames, StringBuilder buf) To string, param value only.Methods inherited from class ScanResultObject
findReferencedClassInfo, loadClass, loadClass, loadClass, loadClass, toString, toString, toStringWithSimpleNames
-
Field Details
-
name
The the parameter name. -
value
The parameter value.
-
-
Constructor Details
-
AnnotationParameterValue
AnnotationParameterValue()Default constructor for deserialization. -
AnnotationParameterValue
-
-
Method Details
-
getName
-
getValue
Get the annotation parameter value.- Returns:
- The annotation parameter value. May be one of the following types:
- String for string constants
- String[] for arrays of strings
- A boxed type, e.g. Integer or Character, for primitive-typed constants
- A 1-dimensional primitive-typed array (i.e. int[], long[], short[], char[], byte[], boolean[], float[], or double[]), for arrays of primitives
- A 1-dimensional
Object[] array for array types (and then the array element type may be one of the types in this list) AnnotationEnumValue, for enum constants (this wraps the enum class and the string name of the constant)AnnotationClassRef, for Class references within annotations (this wraps the name of the referenced class)AnnotationInfo, for nested annotations
-
setValue
Set (update) the value of the annotation parameter. Used to replace Object[] arrays containing boxed types into primitive arrays.- Parameters:
newValue- the new value
-
getClassName
Description copied from class:ScanResultObjectThe name of the class (used byScanResultObject.getClassInfo()to fetch theClassInfoobject for the class).- Specified by:
getClassNamein classScanResultObject- Returns:
- The class name.
-
getClassInfo
Description copied from class:ScanResultObjectGet theClassInfoobject for the referenced class, or null if the referenced class was not encountered during scanning (i.e. no ClassInfo object was created for the class during scanning). N.B. even if this method returns null,ScanResultObject.loadClass()may be able to load the referenced class by name.- Overrides:
getClassInfoin classScanResultObject- Returns:
- The
ClassInfoobject for the referenced class.
-
setScanResult
Description copied from class:ScanResultObjectSet ScanResult backreferences in info objects after scan has completed.- Overrides:
setScanResultin classScanResultObject- Parameters:
scanResult- the scan result
-
findReferencedClassInfo
protected void findReferencedClassInfo(Map<String, ClassInfo> classNameToClassInfo, Set<ClassInfo> refdClassInfo, LogNode log) GetClassInfoobjects for any classes referenced in the annotation parameters.- Overrides:
findReferencedClassInfoin classScanResultObject- Parameters:
classNameToClassInfo- the map from class name toClassInfo.refdClassInfo- the referenced class infolog- the log
-
convertWrapperArraysToPrimitiveArrays
For primitive array type params, replace Object[] arrays containing boxed types with primitive arrays (need to check the type of each method of the annotation class to determine if it is a primitive array type).- Parameters:
annotationClassInfo- the annotation class info
-
instantiate
-
compareTo
- Specified by:
compareToin interfaceComparable<AnnotationParameterValue>
-
equals
-
hashCode
-
toString
Description copied from class:ScanResultObjectRender to string.- Specified by:
toStringin classScanResultObject- Parameters:
useSimpleNames- if true, use just the simple name of each class.buf- the buf
-
toString
Write an annotation parameter value's string representation to the buffer.- Parameters:
val- the valueuseSimpleNames- the use simple namesbuf- the buffer
-
toStringParamValueOnly
To string, param value only.- Parameters:
buf- the buf
-
toStringParamValueOnly
-