Package io.github.classgraph
Class MethodParameterInfo
- java.lang.Object
-
- io.github.classgraph.MethodParameterInfo
-
public class MethodParameterInfo extends java.lang.ObjectInformation on the parameters of a method.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) AnnotationInfo[]annotationInfoThe annotation info.private MethodInfomethodInfoThe containing method.private intmodifiersThe modifiers.private java.lang.StringnameThe parameter name.private ScanResultscanResultThe scan result.private TypeSignaturetypeDescriptorThe type descriptor.private TypeSignaturetypeSignatureThe type signature.
-
Constructor Summary
Constructors Constructor Description MethodParameterInfo(MethodInfo methodInfo, AnnotationInfo[] annotationInfo, int modifiers, TypeSignature typeDescriptor, TypeSignature typeSignature, java.lang.String name)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)AnnotationInfoListgetAnnotationInfo()Method parameter annotation info (or null if no annotations).AnnotationInfogetAnnotationInfo(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)Get a the non-Repeatableannotation on this method, or null if the method parameter does not have the annotation.AnnotationInfogetAnnotationInfo(java.lang.String annotationName)Get a the named non-Repeatableannotation on this method, or null if the method parameter does not have the named annotation.AnnotationInfoListgetAnnotationInfoRepeatable(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)Get a theRepeatableannotation on this method, or the empty list if the method parameter does not have the annotation.AnnotationInfoListgetAnnotationInfoRepeatable(java.lang.String annotationName)Get a the namedRepeatableannotation on this method, or the empty list if the method parameter does not have the named annotation.MethodInfogetMethodInfo()Get theMethodInfofor the defining method.intgetModifiers()Method parameter modifiers.java.lang.StringgetModifiersStr()Get the method parameter modifiers as a String, e.g.java.lang.StringgetName()Method parameter name.TypeSignaturegetTypeDescriptor()Method parameter type descriptor.TypeSignaturegetTypeSignature()Method parameter type signature, possibly including generic type information (or null if no type signature information available for this parameter).TypeSignaturegetTypeSignatureOrTypeDescriptor()Method parameter type signature, or if not available, method type descriptor.booleanhasAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)Check whether this method parameter has the annotation.booleanhasAnnotation(java.lang.String annotationName)Check whether this method parameter has the named annotation.inthashCode()booleanisFinal()Returns true if this method parameter is final.booleanisMandated()Returns true if this method parameter is mandated.booleanisSynthetic()Returns true if this method parameter is synthetic.(package private) static voidmodifiersToString(int modifiers, java.lang.StringBuilder buf)Convert modifiers into a string representation, e.g.protected voidsetScanResult(ScanResult scanResult)Sets the scan result.java.lang.StringtoString()Render to string.protected voidtoString(boolean useSimpleNames, java.lang.StringBuilder buf)Render to string.java.lang.StringtoStringWithSimpleNames()Render to string with simple names for classes.
-
-
-
Field Detail
-
methodInfo
private final MethodInfo methodInfo
The containing method.
-
annotationInfo
final AnnotationInfo[] annotationInfo
The annotation info.
-
modifiers
private final int modifiers
The modifiers.
-
typeDescriptor
private final TypeSignature typeDescriptor
The type descriptor.
-
typeSignature
private final TypeSignature typeSignature
The type signature.
-
name
private final java.lang.String name
The parameter name.
-
scanResult
private ScanResult scanResult
The scan result.
-
-
Constructor Detail
-
MethodParameterInfo
MethodParameterInfo(MethodInfo methodInfo, AnnotationInfo[] annotationInfo, int modifiers, TypeSignature typeDescriptor, TypeSignature typeSignature, java.lang.String name)
Constructor.- Parameters:
methodInfo- TheMethodInfofor the defining method.annotationInfo-AnnotationInfofor any annotations on this method parameter.modifiers- The method parameter modifiers.typeDescriptor- The method parameter type descriptor.typeSignature- The method parameter type signature.name- The method parameter name.
-
-
Method Detail
-
getMethodInfo
public MethodInfo getMethodInfo()
Get theMethodInfofor the defining method.- Returns:
- The
MethodInfofor the defining method.
-
getName
public java.lang.String getName()
Method parameter name. May be null, for unnamed parameters (e.g. synthetic parameters), or if compiled for JDK version lower than 8, or if compiled for JDK version 8+ but without the commandline switch `-parameters`.- Returns:
- The method parameter name.
-
getModifiers
public int getModifiers()
Method parameter modifiers. May be zero, if no modifier bits set, or if compiled for JDK version lower than 8, or if compiled for JDK version 8+ but without the commandline switch `-parameters`.- Returns:
- The method parameter modifiers.
-
getModifiersStr
public java.lang.String getModifiersStr()
Get the method parameter modifiers as a String, e.g. "final". For the modifier bits, callgetModifiers().- Returns:
- The modifiers for the method parameter, as a String.
-
getTypeSignature
public TypeSignature getTypeSignature()
Method parameter type signature, possibly including generic type information (or null if no type signature information available for this parameter).- Returns:
- The method type signature, if available, else null.
-
getTypeDescriptor
public TypeSignature getTypeDescriptor()
Method parameter type descriptor.- Returns:
- The method type descriptor.
-
getTypeSignatureOrTypeDescriptor
public TypeSignature getTypeSignatureOrTypeDescriptor()
Method parameter type signature, or if not available, method type descriptor.- Returns:
- The method type signature, if present, otherwise the method type descriptor.
-
getAnnotationInfo
public AnnotationInfoList getAnnotationInfo()
Method parameter annotation info (or null if no annotations).- Returns:
AnnotationInfofor any annotations on this method parameter.
-
getAnnotationInfo
public AnnotationInfo getAnnotationInfo(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Get a the non-Repeatableannotation on this method, or null if the method parameter does not have the annotation. (UsegetAnnotationInfoRepeatable(Class)forRepeatableannotations.)- Parameters:
annotation- The annotation.- Returns:
- An
AnnotationInfoobject representing the annotation on this method parameter, or null if the method parameter does not have the annotation.
-
getAnnotationInfo
public AnnotationInfo getAnnotationInfo(java.lang.String annotationName)
Get a the named non-Repeatableannotation on this method, or null if the method parameter does not have the named annotation. (UsegetAnnotationInfoRepeatable(String)forRepeatableannotations.)- Parameters:
annotationName- The annotation name.- Returns:
- An
AnnotationInfoobject representing the named annotation on this method parameter, or null if the method parameter does not have the named annotation.
-
getAnnotationInfoRepeatable
public AnnotationInfoList getAnnotationInfoRepeatable(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Get a theRepeatableannotation on this method, or the empty list if the method parameter does not have the annotation.- Parameters:
annotation- The annotation.- Returns:
- An
AnnotationInfoListcontaining all instances of the annotation on this method parameter, or the empty list if the method parameter does not have the annotation.
-
getAnnotationInfoRepeatable
public AnnotationInfoList getAnnotationInfoRepeatable(java.lang.String annotationName)
Get a the namedRepeatableannotation on this method, or the empty list if the method parameter does not have the named annotation.- Parameters:
annotationName- The annotation name.- Returns:
- An
AnnotationInfoListcontaining all instances of the named annotation on this method parameter, or the empty list if the method parameter does not have the named annotation.
-
hasAnnotation
public boolean hasAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Check whether this method parameter has the annotation.- Parameters:
annotation- The annotation.- Returns:
- true if this method parameter has the annotation.
-
hasAnnotation
public boolean hasAnnotation(java.lang.String annotationName)
Check whether this method parameter has the named annotation.- Parameters:
annotationName- The name of an annotation.- Returns:
- true if this method parameter has the named annotation.
-
setScanResult
protected void setScanResult(ScanResult scanResult)
Sets the scan result.- Parameters:
scanResult- the new scan result
-
isFinal
public boolean isFinal()
Returns true if this method parameter is final.- Returns:
- True if this method parameter is final.
-
isSynthetic
public boolean isSynthetic()
Returns true if this method parameter is synthetic.- Returns:
- True if this method parameter is synthetic.
-
isMandated
public boolean isMandated()
Returns true if this method parameter is mandated.- Returns:
- True if this method parameter is mandated.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
modifiersToString
static void modifiersToString(int modifiers, java.lang.StringBuilder buf)Convert modifiers into a string representation, e.g. "public static final".- Parameters:
modifiers- The field or method modifiers.buf- The buffer to write the result into.
-
toString
protected void toString(boolean useSimpleNames, java.lang.StringBuilder buf)Render to string.- Parameters:
useSimpleNames- if true, use just the simple name of each class.buf- the buf
-
toStringWithSimpleNames
public java.lang.String toStringWithSimpleNames()
Render to string with simple names for classes.- Returns:
- the string representation.
-
toString
public java.lang.String toString()
Render to string.- Overrides:
toStringin classjava.lang.Object- Returns:
- the string representation.
-
-