Package io.github.classgraph
Class MethodTypeSignature
- java.lang.Object
-
- io.github.classgraph.ScanResultObject
-
- io.github.classgraph.HierarchicalTypeSignature
-
- io.github.classgraph.MethodTypeSignature
-
public final class MethodTypeSignature extends HierarchicalTypeSignature
A method type signature (called "MethodSignature" in the classfile documentation).
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<TypeSignature>parameterTypeSignaturesThe method parameter type signatures.private AnnotationInfoListreceiverTypeAnnotationInfoAny type annotation(s) on an explicit receiver parameter.private TypeSignatureresultTypeThe method result type.private java.util.List<ClassRefOrTypeVariableSignature>throwsSignaturesThe throws type signatures.(package private) java.util.List<TypeParameter>typeParametersThe method type parameters.-
Fields inherited from class io.github.classgraph.HierarchicalTypeSignature
typeAnnotationInfo
-
Fields inherited from class io.github.classgraph.ScanResultObject
classRef, scanResult
-
-
Constructor Summary
Constructors Modifier Constructor Description privateMethodTypeSignature(java.util.List<TypeParameter> typeParameters, java.util.List<TypeSignature> paramTypes, TypeSignature resultType, java.util.List<ClassRefOrTypeVariableSignature> throwsSignatures)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidaddRecieverTypeAnnotation(AnnotationInfo annotationInfo)Add a type annotation for an explicit receiver parameter.protected voidaddTypeAnnotation(java.util.List<Classfile.TypePathNode> typePath, AnnotationInfo annotationInfo)Add a type annotation.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 type descriptor or type signature.protected voidfindReferencedClassNames(java.util.Set<java.lang.String> refdClassNames)Get the names of any classes referenced in the type signature.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).(package private) java.util.List<TypeSignature>getParameterTypeSignatures()Get the type signatures of the method parameters.AnnotationInfoListgetReceiverTypeAnnotationInfo()Get type annotations on the explicit receiver parameter, or null if none.TypeSignaturegetResultType()Get the result type for the method.java.util.List<ClassRefOrTypeVariableSignature>getThrowsSignatures()Get the throws type(s) for the method.java.util.List<TypeParameter>getTypeParameters()Get the type parameters for the method, if this is a generic method.inthashCode()(package private) static MethodTypeSignatureparse(java.lang.String typeDescriptor, java.lang.String definingClassName)Parse a method signature.(package private) voidsetScanResult(ScanResult scanResult)Set ScanResult backreferences in info objects after scan has completed.protected voidtoStringInternal(boolean useSimpleNames, AnnotationInfoList annotationsToExclude, java.lang.StringBuilder buf)Render type signature to string.-
Methods inherited from class io.github.classgraph.HierarchicalTypeSignature
addTypeAnnotation, getTypeAnnotationInfo, toString
-
Methods inherited from class io.github.classgraph.ScanResultObject
findReferencedClassInfo, loadClass, loadClass, loadClass, loadClass, toString, toString, toStringWithSimpleNames
-
-
-
-
Field Detail
-
typeParameters
final java.util.List<TypeParameter> typeParameters
The method type parameters.
-
parameterTypeSignatures
private final java.util.List<TypeSignature> parameterTypeSignatures
The method parameter type signatures.
-
resultType
private final TypeSignature resultType
The method result type.
-
throwsSignatures
private final java.util.List<ClassRefOrTypeVariableSignature> throwsSignatures
The throws type signatures.
-
receiverTypeAnnotationInfo
private AnnotationInfoList receiverTypeAnnotationInfo
Any type annotation(s) on an explicit receiver parameter.
-
-
Constructor Detail
-
MethodTypeSignature
private MethodTypeSignature(java.util.List<TypeParameter> typeParameters, java.util.List<TypeSignature> paramTypes, TypeSignature resultType, java.util.List<ClassRefOrTypeVariableSignature> throwsSignatures)
Constructor.- Parameters:
typeParameters- The type parameters for the method.paramTypes- The parameter types for the method.resultType- The return type for the method.throwsSignatures- The throws signatures for the method.
-
-
Method Detail
-
getTypeParameters
public java.util.List<TypeParameter> getTypeParameters()
Get the type parameters for the method, if this is a generic method.- Returns:
- The type parameters for the method, if any, otherwise null.
-
getParameterTypeSignatures
java.util.List<TypeSignature> getParameterTypeSignatures()
Get the type signatures of the method parameters. N.B. this is non-public, since the types have to be aligned with other parameter metadata. The type of a parameter can be obtained post-alignment from the parameter'sMethodParameterInfoobject.- Returns:
- The parameter types for the method, as
TypeSignatureparsed type objects.
-
getResultType
public TypeSignature getResultType()
Get the result type for the method.- Returns:
- The result type for the method, as a
TypeSignatureparsed type object.
-
getThrowsSignatures
public java.util.List<ClassRefOrTypeVariableSignature> getThrowsSignatures()
Get the throws type(s) for the method.- Returns:
- The throws types for the method, as
TypeSignatureparsed type objects.
-
addTypeAnnotation
protected void addTypeAnnotation(java.util.List<Classfile.TypePathNode> typePath, AnnotationInfo annotationInfo)
Description copied from class:HierarchicalTypeSignatureAdd a type annotation.- Specified by:
addTypeAnnotationin classHierarchicalTypeSignature- Parameters:
typePath- the type pathannotationInfo- the annotation
-
addRecieverTypeAnnotation
void addRecieverTypeAnnotation(AnnotationInfo annotationInfo)
Add a type annotation for an explicit receiver parameter.- Parameters:
annotationInfo- the receiver type annotation
-
getReceiverTypeAnnotationInfo
public AnnotationInfoList getReceiverTypeAnnotationInfo()
Get type annotations on the explicit receiver parameter, or null if none.- Returns:
- type annotations on the explicit receiver parameter, or null if none.
-
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 classHierarchicalTypeSignature- Parameters:
scanResult- the scan result
-
findReferencedClassNames
protected void findReferencedClassNames(java.util.Set<java.lang.String> refdClassNames)
Get the names of any classes referenced in the type signature.- Parameters:
refdClassNames- the referenced class names.
-
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 type descriptor or type signature.- Overrides:
findReferencedClassInfoin classScanResultObject- Parameters:
classNameToClassInfo- the map from class name toClassInfo.refdClassInfo- the referenced class infolog- the log
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toStringInternal
protected void toStringInternal(boolean useSimpleNames, AnnotationInfoList annotationsToExclude, java.lang.StringBuilder buf)Description copied from class:HierarchicalTypeSignatureRender type signature to string.- Specified by:
toStringInternalin classHierarchicalTypeSignature- Parameters:
useSimpleNames- whether to use simple names for classes.annotationsToExclude- toplevel annotations to exclude, to eliminate duplication (toplevel annotations are both class/field/method annotations and type annotations).buf- theStringBuilderto write to.
-
parse
static MethodTypeSignature parse(java.lang.String typeDescriptor, java.lang.String definingClassName) throws ParseException
Parse a method signature.- Parameters:
typeDescriptor- The type descriptor of the method.definingClassName- The name of the defining class (for resolving type variables).- Returns:
- The parsed method type signature.
- Throws:
ParseException- If method type signature could not be parsed.
-
-