Package io.github.classgraph
Class MethodTypeSignature
java.lang.Object
io.github.classgraph.ScanResultObject
io.github.classgraph.HierarchicalTypeSignature
io.github.classgraph.MethodTypeSignature
A method type signature (called "MethodSignature" in the classfile documentation).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List
<TypeSignature> The method parameter type signatures.private AnnotationInfoList
Any type annotation(s) on an explicit receiver parameter.private final TypeSignature
The method result type.private final List
<ClassRefOrTypeVariableSignature> The throws type signatures.(package private) final List
<TypeParameter> The method type parameters.Fields inherited from class io.github.classgraph.HierarchicalTypeSignature
typeAnnotationInfo
Fields inherited from class io.github.classgraph.ScanResultObject
classRef, scanResult
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
MethodTypeSignature
(List<TypeParameter> typeParameters, List<TypeSignature> paramTypes, TypeSignature resultType, List<ClassRefOrTypeVariableSignature> throwsSignatures) Constructor. -
Method Summary
Modifier and TypeMethodDescription(package private) void
addRecieverTypeAnnotation
(AnnotationInfo annotationInfo) Add a type annotation for an explicit receiver parameter.protected void
addTypeAnnotation
(List<Classfile.TypePathNode> typePath, AnnotationInfo annotationInfo) Add a type annotation.boolean
protected void
findReferencedClassInfo
(Map<String, ClassInfo> classNameToClassInfo, Set<ClassInfo> refdClassInfo, LogNode log) GetClassInfo
objects for any classes referenced in the type descriptor or type signature.protected void
findReferencedClassNames
(Set<String> refdClassNames) Get the names of any classes referenced in the type signature.protected ClassInfo
Get theClassInfo
object for the referenced class, or null if the referenced class was not encountered during scanning (i.e.protected String
The name of the class (used byScanResultObject.getClassInfo()
to fetch theClassInfo
object for the class).(package private) List
<TypeSignature> Get the type signatures of the method parameters.Get type annotations on the explicit receiver parameter, or null if none.Get the result type for the method.Get the throws type(s) for the method.Get the type parameters for the method, if this is a generic method.int
hashCode()
(package private) static MethodTypeSignature
Parse a method signature.(package private) void
setScanResult
(ScanResult scanResult) Set ScanResult backreferences in info objects after scan has completed.protected void
toStringInternal
(boolean useSimpleNames, AnnotationInfoList annotationsToExclude, 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 Details
-
typeParameters
The method type parameters. -
parameterTypeSignatures
The method parameter type signatures. -
resultType
The method result type. -
throwsSignatures
The throws type signatures. -
receiverTypeAnnotationInfo
Any type annotation(s) on an explicit receiver parameter.
-
-
Constructor Details
-
MethodTypeSignature
private MethodTypeSignature(List<TypeParameter> typeParameters, List<TypeSignature> paramTypes, TypeSignature resultType, 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 Details
-
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
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'sMethodParameterInfo
object.- Returns:
- The parameter types for the method, as
TypeSignature
parsed type objects.
-
getResultType
Get the result type for the method.- Returns:
- The result type for the method, as a
TypeSignature
parsed type object.
-
getThrowsSignatures
Get the throws type(s) for the method.- Returns:
- The throws types for the method, as
TypeSignature
parsed type objects.
-
addTypeAnnotation
protected void addTypeAnnotation(List<Classfile.TypePathNode> typePath, AnnotationInfo annotationInfo) Description copied from class:HierarchicalTypeSignature
Add a type annotation.- Specified by:
addTypeAnnotation
in classHierarchicalTypeSignature
- Parameters:
typePath
- the type pathannotationInfo
- the annotation
-
addRecieverTypeAnnotation
Add a type annotation for an explicit receiver parameter.- Parameters:
annotationInfo
- the receiver type annotation
-
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
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
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
Description copied from class:ScanResultObject
Set ScanResult backreferences in info objects after scan has completed.- Overrides:
setScanResult
in classHierarchicalTypeSignature
- Parameters:
scanResult
- the scan result
-
findReferencedClassNames
Get the names of any classes referenced in the type signature.- Parameters:
refdClassNames
- the referenced class names.
-
findReferencedClassInfo
protected void findReferencedClassInfo(Map<String, ClassInfo> classNameToClassInfo, Set<ClassInfo> refdClassInfo, LogNode log) GetClassInfo
objects for any classes referenced in the type descriptor or type signature.- Overrides:
findReferencedClassInfo
in classScanResultObject
- Parameters:
classNameToClassInfo
- the map from class name toClassInfo
.refdClassInfo
- the referenced class infolog
- the log
-
hashCode
public int hashCode() -
equals
-
toStringInternal
protected void toStringInternal(boolean useSimpleNames, AnnotationInfoList annotationsToExclude, StringBuilder buf) Description copied from class:HierarchicalTypeSignature
Render type signature to string.- Specified by:
toStringInternal
in 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
- theStringBuilder
to write to.
-
parse
static MethodTypeSignature parse(String typeDescriptor, 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.
-