public class MethodInfo extends Object implements Comparable<MethodInfo>, HasName
Modifier and Type | Method and Description |
---|---|
int |
compareTo(MethodInfo other)
Sort in order of class name, method name, then type descriptor.
|
boolean |
equals(Object obj)
Test class name, method name and type descriptor for equals().
|
AnnotationInfoList |
getAnnotationInfo()
Get a list of annotations on this method, along with any annotation parameter values.
|
AnnotationInfo |
getAnnotationInfo(String annotationName)
Get a the named non-
Repeatable annotation on this method, or null if the method does not have the
named annotation. |
AnnotationInfoList |
getAnnotationInfoRepeatable(String annotationName)
Get a the named
Repeatable annotation on this method, or the empty list if the method does not have
the named annotation. |
ClassInfo |
getClassInfo()
Get the
ClassInfo object for the declaring class (i.e. |
int |
getModifiers()
Returns the modifier bits for the method.
|
String |
getModifiersStr()
Get the method modifiers as a String, e.g.
|
String |
getName()
Returns the name of the method.
|
MethodParameterInfo[] |
getParameterInfo()
Get the available information on method parameters.
|
MethodTypeSignature |
getTypeDescriptor()
Returns the parsed type descriptor for the method, which will not include type parameters.
|
String |
getTypeDescriptorStr()
Returns the type descriptor string for the method, which will not include type parameters.
|
MethodTypeSignature |
getTypeSignature()
Returns the parsed type signature for the method, possibly including type parameters.
|
MethodTypeSignature |
getTypeSignatureOrTypeDescriptor()
Returns the parsed type signature for the method, possibly including type parameters.
|
String |
getTypeSignatureOrTypeDescriptorStr()
Returns the type signature string for the method, possibly including type parameters.
|
String |
getTypeSignatureStr()
Returns the type signature string for the method, possibly including type parameters.
|
boolean |
hasAnnotation(String annotationName)
Check if this method has the named annotation.
|
boolean |
hasBody()
Returns true if this method has a body (i.e.
|
int |
hashCode()
Use hashcode of class name, method name and type descriptor.
|
boolean |
hasParameterAnnotation(String annotationName)
Check if this method has a parameter with the named annotation.
|
boolean |
isBridge()
Returns true if this method is a bridge method.
|
boolean |
isConstructor()
Returns true if this method is a constructor.
|
boolean |
isDefault()
Returns true if this is a default method (i.e.
|
boolean |
isFinal()
Returns true if this method is final.
|
boolean |
isNative()
Returns true if this method is a native method.
|
boolean |
isPublic()
Returns true if this method is public.
|
boolean |
isStatic()
Returns true if this method is static.
|
boolean |
isSynchronized()
Returns true if this method is synchronized.
|
boolean |
isSynthetic()
Returns true if this method is synthetic.
|
boolean |
isVarArgs()
Returns true if this method is a varargs method.
|
Constructor<?> |
loadClassAndGetConstructor()
Load the class this constructor is associated with, and get the
Constructor reference for this
constructor. |
Method |
loadClassAndGetMethod()
Load the class this method is associated with, and get the
Method reference for this method. |
String |
toString()
Render to string.
|
String |
toStringWithSimpleNames()
Render to string, using only simple names for classes.
|
public String getName()
"<init>"
, and private static class
initializer blocks are named "<clinit>"
.public int getModifiers()
public String getModifiersStr()
getModifiers()
.public ClassInfo getClassInfo()
ClassInfo
object for the declaring class (i.e. the class that declares this method).ClassInfo
object for the declaring class (i.e. the class that declares this method).public MethodTypeSignature getTypeDescriptor()
getTypeSignature()
instead.public String getTypeDescriptorStr()
getTypeSignatureStr()
instead.public MethodTypeSignature getTypeSignature()
getTypeDescriptor()
instead.public String getTypeSignatureStr()
getTypeDescriptorStr()
instead.public MethodTypeSignature getTypeSignatureOrTypeDescriptor()
public String getTypeSignatureOrTypeDescriptorStr()
public boolean isConstructor()
"<init>"
. This returns false for private static class initializer blocks, which are named
"<clinit>"
.public boolean isPublic()
public boolean isStatic()
public boolean isFinal()
public boolean isSynchronized()
public boolean isBridge()
public boolean isSynthetic()
public boolean isVarArgs()
public boolean isNative()
public boolean hasBody()
public boolean isDefault()
public MethodParameterInfo[] getParameterInfo()
MethodParameterInfo
objects for the method parameters, one per parameter.public AnnotationInfoList getAnnotationInfo()
AnnotationInfo
objects, or the empty list if none.public AnnotationInfo getAnnotationInfo(String annotationName)
Repeatable
annotation on this method, or null if the method does not have the
named annotation. (Use getAnnotationInfoRepeatable(String)
for Repeatable
annotations.)annotationName
- The annotation name.AnnotationInfo
object representing the named annotation on this method, or null if the
method does not have the named annotation.public AnnotationInfoList getAnnotationInfoRepeatable(String annotationName)
Repeatable
annotation on this method, or the empty list if the method does not have
the named annotation.annotationName
- The annotation name.AnnotationInfoList
containing all instances of the named annotation on this method, or the
empty list if the method does not have the named annotation.public boolean hasAnnotation(String annotationName)
annotationName
- The name of an annotation.public boolean hasParameterAnnotation(String annotationName)
annotationName
- The name of a method parameter annotation.public Method loadClassAndGetMethod() throws IllegalArgumentException
Method
reference for this method. Only
call this if isConstructor()
returns false, otherwise an IllegalArgumentException
will be
thrown. Instead call loadClassAndGetConstructor()
for constructors.Method
reference for this method.IllegalArgumentException
- if the method does not exist, or if the method is a constructor.public Constructor<?> loadClassAndGetConstructor() throws IllegalArgumentException
Constructor
reference for this
constructor. Only call this if isConstructor()
returns true, otherwise an
IllegalArgumentException
will be thrown. Instead call loadClassAndGetMethod()
for non-method
constructors.Constructor
reference for this constructor.IllegalArgumentException
- if the constructor does not exist, or if the method is not a constructor.public boolean equals(Object obj)
public int hashCode()
public int compareTo(MethodInfo other)
compareTo
in interface Comparable<MethodInfo>
other
- the other MethodInfo
to compare.public String toStringWithSimpleNames()
Copyright © 2020. All rights reserved.