Package io.github.classgraph
Class AnnotationParameterValue
- java.lang.Object
-
- io.github.classgraph.ScanResultObject
-
- io.github.classgraph.AnnotationParameterValue
-
- All Implemented Interfaces:
HasName,java.lang.Comparable<AnnotationParameterValue>
public class AnnotationParameterValue extends ScanResultObject implements HasName, java.lang.Comparable<AnnotationParameterValue>
A wrapper used to pair annotation parameter names with annotation parameter values.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringnameThe the parameter name.private ObjectTypedValueWrappervalueThe parameter value.-
Fields inherited from class io.github.classgraph.ScanResultObject
classRef, scanResult
-
-
Constructor Summary
Constructors Constructor Description AnnotationParameterValue()Default constructor for deserialization.AnnotationParameterValue(java.lang.String name, java.lang.Object value)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(AnnotationParameterValue other)(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).booleanequals(java.lang.Object obj)protected voidfindReferencedClassInfo(java.util.Map<java.lang.String,ClassInfo> classNameToClassInfo, java.util.Set<ClassInfo> refdClassInfo, LogNode log)GetClassInfoobjects for any classes referenced in the annotation parameters.protected ClassInfogetClassInfo()Get theClassInfoobject for the referenced class, or null if the referenced class was not encountered during scanning (i.e.protected java.lang.StringgetClassName()The name of the class (used byScanResultObject.getClassInfo()to fetch theClassInfoobject for the class).java.lang.StringgetName()Get the annotation parameter name.java.lang.ObjectgetValue()Get the annotation parameter value.inthashCode()(package private) java.lang.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) voidsetValue(java.lang.Object newValue)Set (update) the value of the annotation parameter.protected voidtoString(boolean useSimpleNames, java.lang.StringBuilder buf)Render to string.private static voidtoString(java.lang.Object val, boolean useSimpleNames, java.lang.StringBuilder buf)Write an annotation parameter value's string representation to the buffer.private java.lang.StringtoStringParamValueOnly()To string, param value only.(package private) voidtoStringParamValueOnly(boolean useSimpleNames, java.lang.StringBuilder buf)To string, param value only.-
Methods inherited from class io.github.classgraph.ScanResultObject
findReferencedClassInfo, loadClass, loadClass, loadClass, loadClass, toString, toString, toStringWithSimpleNames
-
-
-
-
Field Detail
-
name
private java.lang.String name
The the parameter name.
-
value
private ObjectTypedValueWrapper value
The parameter value.
-
-
Constructor Detail
-
AnnotationParameterValue
AnnotationParameterValue()
Default constructor for deserialization.
-
AnnotationParameterValue
AnnotationParameterValue(java.lang.String name, java.lang.Object value)Constructor.- Parameters:
name- The annotation paramater name.value- The annotation parameter value.
-
-
Method Detail
-
getName
public java.lang.String getName()
Get the annotation parameter name.
-
getValue
public java.lang.Object 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
void setValue(java.lang.Object newValue)
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
protected java.lang.String 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
protected ClassInfo 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
void setScanResult(ScanResult scanResult)
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(java.util.Map<java.lang.String,ClassInfo> classNameToClassInfo, java.util.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
void convertWrapperArraysToPrimitiveArrays(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).- Parameters:
annotationClassInfo- the annotation class info
-
instantiate
java.lang.Object instantiate(ClassInfo annotationClassInfo)
Instantiate an annotation parameter value.- Parameters:
annotationClassInfo- the annotation class info- Returns:
- the instance
-
compareTo
public int compareTo(AnnotationParameterValue other)
- Specified by:
compareToin interfacejava.lang.Comparable<AnnotationParameterValue>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
protected void toString(boolean useSimpleNames, java.lang.StringBuilder buf)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
private static void toString(java.lang.Object val, boolean useSimpleNames, java.lang.StringBuilder buf)Write an annotation parameter value's string representation to the buffer.- Parameters:
val- the valueuseSimpleNames- the use simple namesbuf- the buffer
-
toStringParamValueOnly
void toStringParamValueOnly(boolean useSimpleNames, java.lang.StringBuilder buf)To string, param value only.- Parameters:
buf- the buf
-
toStringParamValueOnly
private java.lang.String toStringParamValueOnly()
To string, param value only.- Returns:
- the string.
-
-