Class AnnotationInfo

    • Field Detail

      • name

        private java.lang.String name
        The name.
      • annotationParamValuesHasBeenConvertedToPrimitive

        private transient boolean annotationParamValuesHasBeenConvertedToPrimitive
        Set to true once any Object[] arrays of boxed types in annotationParamValues have been lazily converted to primitive arrays.
      • annotationParamValuesWithDefaults

        private transient AnnotationParameterValueList annotationParamValuesWithDefaults
        The annotation param values with defaults.
    • Constructor Detail

      • AnnotationInfo

        AnnotationInfo()
        Default constructor for deserialization.
      • AnnotationInfo

        AnnotationInfo​(java.lang.String name,
                       AnnotationParameterValueList annotationParamValues)
        Constructor.
        Parameters:
        name - The name of the annotation.
        annotationParamValues - The annotation parameter values, or null if none.
    • Method Detail

      • getName

        public java.lang.String getName()
        Get the name.
        Specified by:
        getName in interface HasName
        Returns:
        The name of the annotation class.
      • isInherited

        public boolean isInherited()
        Checks if the annotation is inherited.
        Returns:
        true if this annotation is meta-annotated with Inherited.
      • getDefaultParameterValues

        public AnnotationParameterValueList getDefaultParameterValues()
        Get the default parameter values.
        Returns:
        the list of default parameter values for this annotation, or the empty list if none.
      • getParameterValues

        public AnnotationParameterValueList getParameterValues​(boolean includeDefaultValues)
        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

        public AnnotationParameterValueList 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.
      • 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​(java.util.Map<java.lang.String,​ClassInfo> classNameToClassInfo,
                                               java.util.Set<ClassInfo> refdClassInfo,
                                               LogNode log)
        Get ClassInfo objects for any classes referenced in the type descriptor or type signature.
        Overrides:
        findReferencedClassInfo in class ScanResultObject
        Parameters:
        classNameToClassInfo - the map from class name to ClassInfo.
        refdClassInfo - the referenced class info
        log - the log
      • loadClassAndInstantiate

        public java.lang.annotation.Annotation loadClassAndInstantiate()
        Load the Annotation class corresponding to this AnnotationInfo object, by calling getClassInfo().loadClass(), then create a new instance of the annotation, with the annotation parameter values obtained from this AnnotationInfo object, possibly overriding default annotation parameter values obtained from calling getClassInfo() then ClassInfo.getAnnotationDefaultParameterValues().

        Note that the returned Annotation will have some sort of InvocationHandler proxy type, such as io.github.classgraph.features.$Proxy4 or com.sun.proxy.$Proxy6. This is an unavoidable side effect of the fact that concrete Annotation 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 and instanceof: you are able to cast the returned proxy instance to the annotation type, and instanceof 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 call ClassInfo.loadClass(), and read the annotations directly from the returned Class 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.
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

        protected void toString​(boolean useSimpleNames,
                                java.lang.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