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 Details

  • Constructor Details

    • AnnotationParameterValue

      AnnotationParameterValue()
      Default constructor for deserialization.
    • AnnotationParameterValue

      AnnotationParameterValue(String name, Object value)
      Constructor.
      Parameters:
      name - The annotation paramater name.
      value - The annotation parameter value.
  • Method Details

    • getName

      public String getName()
      Get the annotation parameter name.
      Specified by:
      getName in interface HasName
      Returns:
      The annotation parameter name.
    • getValue

      public 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(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 String getClassName()
      Description copied from class: ScanResultObject
      The name of the class (used by ScanResultObject.getClassInfo() to fetch the ClassInfo object for the class).
      Specified by:
      getClassName in class ScanResultObject
      Returns:
      The class name.
    • getClassInfo

      protected ClassInfo getClassInfo()
      Description copied from class: ScanResultObject
      Get the ClassInfo 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 class ScanResultObject
      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 class ScanResultObject
      Parameters:
      scanResult - the scan result
    • findReferencedClassInfo

      protected void findReferencedClassInfo(Map<String,ClassInfo> classNameToClassInfo, Set<ClassInfo> refdClassInfo, LogNode log)
      Get ClassInfo objects for any classes referenced in the annotation parameters.
      Overrides:
      findReferencedClassInfo in class ScanResultObject
      Parameters:
      classNameToClassInfo - the map from class name to ClassInfo.
      refdClassInfo - the referenced class info
      log - 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

      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 interface Comparable<AnnotationParameterValue>
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      protected void toString(boolean useSimpleNames, StringBuilder buf)
      Description copied from class: ScanResultObject
      Render to string.
      Specified by:
      toString in class ScanResultObject
      Parameters:
      useSimpleNames - if true, use just the simple name of each class.
      buf - the buf
    • toString

      private static void toString(Object val, boolean useSimpleNames, StringBuilder buf)
      Write an annotation parameter value's string representation to the buffer.
      Parameters:
      val - the value
      useSimpleNames - the use simple names
      buf - the buffer
    • toStringParamValueOnly

      void toStringParamValueOnly(boolean useSimpleNames, StringBuilder buf)
      To string, param value only.
      Parameters:
      buf - the buf
    • toStringParamValueOnly

      private String toStringParamValueOnly()
      To string, param value only.
      Returns:
      the string.