Package io.github.classgraph
Class ClassMemberInfo
- java.lang.Object
-
- io.github.classgraph.ScanResultObject
-
- io.github.classgraph.ClassMemberInfo
-
- All Implemented Interfaces:
HasName
- Direct Known Subclasses:
FieldInfo
,MethodInfo
public abstract class ClassMemberInfo extends ScanResultObject implements HasName
Holds metadata about class members of a class encountered during a scan. All values are taken directly out of the classfile for the class.
-
-
Field Summary
Fields Modifier and Type Field Description protected AnnotationInfoList
annotationInfo
The annotation on the class member, if any.protected java.lang.String
declaringClassName
Defining class name.protected int
modifiers
Class member modifiers.protected java.lang.String
name
The name of the class member.protected java.lang.String
typeDescriptorStr
The JVM-internal type descriptor (missing type parameters, but including types for synthetic and mandated class member parameters).protected java.lang.String
typeSignatureStr
The type signature (may have type parameter information included, if present and available).-
Fields inherited from class io.github.classgraph.ScanResultObject
classRef, scanResult
-
-
Constructor Summary
Constructors Constructor Description ClassMemberInfo()
Default constructor for deserialization.ClassMemberInfo(java.lang.String definingClassName, java.lang.String memberName, int modifiers, java.lang.String typeDescriptorStr, java.lang.String typeSignatureStr, AnnotationInfoList annotationInfo)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description AnnotationInfoList
getAnnotationInfo()
Get a list of annotations on this class member, along with any annotation parameter values, wrapped inAnnotationInfo
objects.AnnotationInfo
getAnnotationInfo(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Get a the non-Repeatable
annotation on this class member, or null if the class member does not have the annotation.AnnotationInfo
getAnnotationInfo(java.lang.String annotationName)
Get a the named non-Repeatable
annotation on this class member, or null if the class member does not have the named annotation.AnnotationInfoList
getAnnotationInfoRepeatable(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Get a theRepeatable
annotation on this class member, or the empty list if the class member does not have the annotation.AnnotationInfoList
getAnnotationInfoRepeatable(java.lang.String annotationName)
Get a the namedRepeatable
annotation on this class member, or the empty list if the class member does not have the named annotation.ClassInfo
getClassInfo()
Get theClassInfo
object for the class that declares this class member.java.lang.String
getClassName()
Get the name of the class that declares this member.int
getModifiers()
Returns the modifier bits for the class member.abstract java.lang.String
getModifiersStr()
Get the modifiers as a string, e.g.java.lang.String
getName()
Get the name of the class member.abstract HierarchicalTypeSignature
getTypeDescriptor()
Returns the parsed type descriptor for the class member, which will not include type parameters.java.lang.String
getTypeDescriptorStr()
Returns the type descriptor string for the class member, which will not include type parameters.abstract HierarchicalTypeSignature
getTypeSignature()
Returns the parsed type signature for the class member, possibly including type parameters.abstract HierarchicalTypeSignature
getTypeSignatureOrTypeDescriptor()
Returns the type signature for the class member, possibly including type parameters.java.lang.String
getTypeSignatureOrTypeDescriptorStr()
Returns the type signature string for the class member, possibly including type parameters.java.lang.String
getTypeSignatureStr()
Returns the type signature string for the class member, possibly including type parameters.boolean
hasAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Check if the class member has a given annotation.boolean
hasAnnotation(java.lang.String annotationName)
Check if the class member has a given named annotation.boolean
isFinal()
Returns true if this class member is final.boolean
isPrivate()
Returns true if this class member is private.boolean
isProtected()
Returns true if this class member is protected.boolean
isPublic()
Returns true if this class member is public.boolean
isStatic()
Returns true if this class member is static.boolean
isSynthetic()
Returns true if this class member is synthetic.-
Methods inherited from class io.github.classgraph.ScanResultObject
findReferencedClassInfo, findReferencedClassInfo, loadClass, loadClass, loadClass, loadClass, setScanResult, toString, toString, toString, toStringWithSimpleNames
-
-
-
-
Field Detail
-
declaringClassName
protected java.lang.String declaringClassName
Defining class name.
-
name
protected java.lang.String name
The name of the class member.
-
modifiers
protected int modifiers
Class member modifiers.
-
typeDescriptorStr
protected java.lang.String typeDescriptorStr
The JVM-internal type descriptor (missing type parameters, but including types for synthetic and mandated class member parameters).
-
typeSignatureStr
protected java.lang.String typeSignatureStr
The type signature (may have type parameter information included, if present and available). Class member parameter types are unaligned.
-
annotationInfo
protected AnnotationInfoList annotationInfo
The annotation on the class member, if any.
-
-
Constructor Detail
-
ClassMemberInfo
ClassMemberInfo()
Default constructor for deserialization.
-
ClassMemberInfo
public ClassMemberInfo(java.lang.String definingClassName, java.lang.String memberName, int modifiers, java.lang.String typeDescriptorStr, java.lang.String typeSignatureStr, AnnotationInfoList annotationInfo)
Constructor.- Parameters:
definingClassName
- The class the member is defined within.memberName
- The name of the class member.modifiers
- The class member modifiers.typeDescriptorStr
- The class member type descriptor.typeSignatureStr
- The class member type signature.annotationInfo
-AnnotationInfo
for any annotations on the class member.
-
-
Method Detail
-
getClassInfo
public ClassInfo getClassInfo()
Get theClassInfo
object for the class that declares this class member.- Overrides:
getClassInfo
in classScanResultObject
- Returns:
- The
ClassInfo
object for the declaring class. - See Also:
getClassName()
-
getClassName
public java.lang.String getClassName()
Get the name of the class that declares this member.- Specified by:
getClassName
in classScanResultObject
- Returns:
- The name of the declaring class.
- See Also:
getClassInfo()
-
getName
public java.lang.String getName()
Get the name of the class member.
-
getModifiers
public int getModifiers()
Returns the modifier bits for the class member.- Returns:
- The modifier bits for the class member.
-
getModifiersStr
public abstract java.lang.String getModifiersStr()
Get the modifiers as a string, e.g. "public static final". For the modifier bits, call getModifiers().- Returns:
- The modifiers modifiers, as a string.
-
isPublic
public boolean isPublic()
Returns true if this class member is public.- Returns:
- True if the class member is public.
-
isPrivate
public boolean isPrivate()
Returns true if this class member is private.- Returns:
- True if the class member is private.
-
isProtected
public boolean isProtected()
Returns true if this class member is protected.- Returns:
- True if the class member is protected.
-
isStatic
public boolean isStatic()
Returns true if this class member is static.- Returns:
- True if the class member is static.
-
isFinal
public boolean isFinal()
Returns true if this class member is final.- Returns:
- True if the class member is final.
-
isSynthetic
public boolean isSynthetic()
Returns true if this class member is synthetic.- Returns:
- True if the class member is synthetic.
-
getTypeDescriptor
public abstract HierarchicalTypeSignature getTypeDescriptor()
Returns the parsed type descriptor for the class member, which will not include type parameters. If you need generic type parameters, callgetTypeSignature()
instead.- Returns:
- The parsed type descriptor string for the class member.
-
getTypeDescriptorStr
public java.lang.String getTypeDescriptorStr()
Returns the type descriptor string for the class member, which will not include type parameters. If you need generic type parameters, callgetTypeSignatureStr()
instead.- Returns:
- The type descriptor string for the class member.
-
getTypeSignature
public abstract HierarchicalTypeSignature getTypeSignature()
Returns the parsed type signature for the class member, possibly including type parameters. If this returns null, that no type signature information is available for this class member, callgetTypeDescriptor()
instead.- Returns:
- The parsed type signature for the class member, or null if not available.
- Throws:
java.lang.IllegalArgumentException
- if the class member type signature cannot be parsed (this should only be thrown in the case of classfile corruption, or a compiler bug that causes an invalid type signature to be written to the classfile).
-
getTypeSignatureStr
public java.lang.String getTypeSignatureStr()
Returns the type signature string for the class member, possibly including type parameters. If this returns null, indicating that no type signature information is available for this class member, callgetTypeDescriptorStr()
instead.- Returns:
- The type signature string for the class member, or null if not available.
-
getTypeSignatureOrTypeDescriptor
public abstract HierarchicalTypeSignature getTypeSignatureOrTypeDescriptor()
Returns the type signature for the class member, possibly including type parameters. If the type signature is null, indicating that no type signature information is available for this class member, returns the type descriptor instead.- Returns:
- The parsed type signature for the class member, or if not available, the parsed type descriptor for the class member.
-
getTypeSignatureOrTypeDescriptorStr
public java.lang.String getTypeSignatureOrTypeDescriptorStr()
Returns the type signature string for the class member, possibly including type parameters. If the type signature string is null, indicating that no type signature information is available for this class member, returns the type descriptor string instead.- Returns:
- The type signature string for the class member, or if not available, the type descriptor string for the class member.
-
getAnnotationInfo
public AnnotationInfoList getAnnotationInfo()
Get a list of annotations on this class member, along with any annotation parameter values, wrapped inAnnotationInfo
objects.- Returns:
- A list of annotations on this class member, along with any annotation parameter values, wrapped in
AnnotationInfo
objects, or the empty list if none.
-
getAnnotationInfo
public AnnotationInfo getAnnotationInfo(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Get a the non-Repeatable
annotation on this class member, or null if the class member does not have the annotation. (UsegetAnnotationInfoRepeatable(Class)
forRepeatable
annotations.)- Parameters:
annotation
- The annotation.- Returns:
- An
AnnotationInfo
object representing the annotation on this class member, or null if the class member does not have the annotation.
-
getAnnotationInfo
public AnnotationInfo getAnnotationInfo(java.lang.String annotationName)
Get a the named non-Repeatable
annotation on this class member, or null if the class member does not have the named annotation. (UsegetAnnotationInfoRepeatable(String)
forRepeatable
annotations.)- Parameters:
annotationName
- The annotation name.- Returns:
- An
AnnotationInfo
object representing the named annotation on this class member, or null if the class member does not have the named annotation.
-
getAnnotationInfoRepeatable
public AnnotationInfoList getAnnotationInfoRepeatable(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Get a theRepeatable
annotation on this class member, or the empty list if the class member does not have the annotation.- Parameters:
annotation
- The annotation.- Returns:
- An
AnnotationInfoList
of all instances of the annotation on this class member, or the empty list if the class member does not have the annotation.
-
getAnnotationInfoRepeatable
public AnnotationInfoList getAnnotationInfoRepeatable(java.lang.String annotationName)
Get a the namedRepeatable
annotation on this class member, or the empty list if the class member does not have the named annotation.- Parameters:
annotationName
- The annotation name.- Returns:
- An
AnnotationInfoList
of all instances of the named annotation on this class member, or the empty list if the class member does not have the named annotation.
-
hasAnnotation
public boolean hasAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Check if the class member has a given annotation.- Parameters:
annotation
- The annotation.- Returns:
- true if this class member has the annotation.
-
hasAnnotation
public boolean hasAnnotation(java.lang.String annotationName)
Check if the class member has a given named annotation.- Parameters:
annotationName
- The name of an annotation.- Returns:
- true if this class member has the named annotation.
-
-