public class MethodDescription extends java.lang.Object implements java.lang.Comparable<MethodDescription>
PlasticMethod
in terms of a method name, a set of modifiers
(public, private, static, final, etc.), a return type, types of method arguments,
and types of checked exceptions. Types are represented as Java source names:
either names of primitives ("void", "byte", "long") or fully qualified class names ("java.lang.Object",
"java.lang.Runnable"). ASM refers to this as "class name".
MethodDescriptions are immutable, and properly implement equals() and hashCode(); they are often used as keys in
Maps.
The natural sort order for a MethodDescription is ascending order by method name, then descending order by number of
parameters (for the same name). Sort order is not currently specified for overrides of the same method with the same
number of parameters.
TODO: Handling generic types.Modifier and Type | Field and Description |
---|---|
java.lang.String[] |
argumentTypes
A non-null array of Java source names for arguments.
|
java.lang.String[] |
checkedExceptionTypes
A non-null array of Java source names for checked exceptions.
|
java.lang.String |
genericSignature |
java.lang.String |
methodName
The name of the method.
|
int |
modifiers
The full set of modifier flags for the method.
|
java.lang.String |
returnType
The Java source name for the return type, e.g., "void", "short", "java.util.Map", "java.lang.String[]".
|
Constructor and Description |
---|
MethodDescription(int modifiers,
java.lang.String returnType,
java.lang.String methodName,
java.lang.String[] argumentTypes,
java.lang.String genericSignature,
java.lang.String[] checkedExceptionTypes) |
MethodDescription(java.lang.reflect.Method method)
Creates a MethodDescription from a Java Method.
|
MethodDescription(java.lang.String returnType,
java.lang.String methodName,
java.lang.String... argumentTypes)
Convenience constructor for public methods that have no checked exceptions.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(MethodDescription o) |
boolean |
equals(java.lang.Object obj) |
int |
hashCode() |
java.lang.String |
toShortString()
A string used to identify the method, containing just the method name and argument types
(but ignoring visibility, return type and thrown exceptions).
|
java.lang.String |
toString() |
MethodDescription |
withModifiers(int newModifiers) |
public final int modifiers
public final java.lang.String returnType
public final java.lang.String methodName
public final java.lang.String genericSignature
public final java.lang.String[] argumentTypes
public final java.lang.String[] checkedExceptionTypes
public MethodDescription(java.lang.String returnType, java.lang.String methodName, java.lang.String... argumentTypes)
returnType
- return type as type namemethodName
- name of methodargumentTypes
- type names for argumentspublic MethodDescription(int modifiers, java.lang.String returnType, java.lang.String methodName, java.lang.String[] argumentTypes, java.lang.String genericSignature, java.lang.String[] checkedExceptionTypes)
modifiers
- returnType
- Java source name for the return typemethodName
- argumentTypes
- may be nullgenericSignature
- TODOcheckedExceptionTypes
- may be nullpublic MethodDescription(java.lang.reflect.Method method)
public MethodDescription withModifiers(int newModifiers)
public int compareTo(MethodDescription o)
compareTo
in interface java.lang.Comparable<MethodDescription>
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toShortString()
${project.version} - Copyright © 2003-2015 The Apache Software Foundation.