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.String
name
The the parameter name.private ObjectTypedValueWrapper
value
The 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 int
compareTo(AnnotationParameterValue other)
(package private) 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).boolean
equals(java.lang.Object obj)
protected void
findReferencedClassInfo(java.util.Map<java.lang.String,ClassInfo> classNameToClassInfo, java.util.Set<ClassInfo> refdClassInfo, LogNode log)
GetClassInfo
objects for any classes referenced in the annotation parameters.protected ClassInfo
getClassInfo()
Get theClassInfo
object for the referenced class, or null if the referenced class was not encountered during scanning (i.e.protected java.lang.String
getClassName()
The name of the class (used byScanResultObject.getClassInfo()
to fetch theClassInfo
object for the class).java.lang.String
getName()
Get the annotation parameter name.java.lang.Object
getValue()
Get the annotation parameter value.int
hashCode()
(package private) java.lang.Object
instantiate(ClassInfo annotationClassInfo)
Instantiate an annotation parameter value.(package private) void
setScanResult(ScanResult scanResult)
Set ScanResult backreferences in info objects after scan has completed.(package private) void
setValue(java.lang.Object newValue)
Set (update) the value of the annotation parameter.protected void
toString(boolean useSimpleNames, java.lang.StringBuilder buf)
Render to string.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.private java.lang.String
toStringParamValueOnly()
To string, param value only.(package private) void
toStringParamValueOnly(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:ScanResultObject
The name of the class (used byScanResultObject.getClassInfo()
to fetch theClassInfo
object for the class).- Specified by:
getClassName
in classScanResultObject
- Returns:
- The class name.
-
getClassInfo
protected ClassInfo getClassInfo()
Description copied from class:ScanResultObject
Get theClassInfo
object 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:
getClassInfo
in classScanResultObject
- Returns:
- The
ClassInfo
object for the referenced class.
-
setScanResult
void setScanResult(ScanResult scanResult)
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(java.util.Map<java.lang.String,ClassInfo> classNameToClassInfo, java.util.Set<ClassInfo> refdClassInfo, LogNode log)
GetClassInfo
objects for any classes referenced in the annotation parameters.- Overrides:
findReferencedClassInfo
in 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:
compareTo
in interfacejava.lang.Comparable<AnnotationParameterValue>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
protected void toString(boolean useSimpleNames, java.lang.StringBuilder buf)
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
-
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.
-
-