public class Method
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
descriptor
The method descriptor.
|
private java.lang.String |
name
The method name.
|
private static java.util.Map<java.lang.String,java.lang.String> |
PRIMITIVE_TYPE_DESCRIPTORS
The descriptors of the primitive Java types (plus void).
|
Constructor and Description |
---|
Method(java.lang.String name,
java.lang.String descriptor)
Constructs a new
Method . |
Method(java.lang.String name,
Type returnType,
Type[] argumentTypes)
Constructs a new
Method . |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object other) |
Type[] |
getArgumentTypes()
Returns the argument types of the method described by this object.
|
java.lang.String |
getDescriptor()
Returns the descriptor of the method described by this object.
|
private static java.lang.String |
getDescriptor(java.lang.String type,
boolean defaultPackage)
Returns the descriptor corresponding to the given type name.
|
static Method |
getMethod(java.lang.reflect.Constructor<?> constructor)
Creates a new
Method . |
static Method |
getMethod(java.lang.reflect.Method method)
Creates a new
Method . |
static Method |
getMethod(java.lang.String method)
Returns a
Method corresponding to the given Java method declaration. |
static Method |
getMethod(java.lang.String method,
boolean defaultPackage)
Returns a
Method corresponding to the given Java method declaration. |
java.lang.String |
getName()
Returns the name of the method described by this object.
|
Type |
getReturnType()
Returns the return type of the method described by this object.
|
int |
hashCode() |
java.lang.String |
toString() |
private final java.lang.String name
private final java.lang.String descriptor
private static final java.util.Map<java.lang.String,java.lang.String> PRIMITIVE_TYPE_DESCRIPTORS
public Method(java.lang.String name, java.lang.String descriptor)
Method
.name
- the method's name.descriptor
- the method's descriptor.public static Method getMethod(java.lang.reflect.Method method)
Method
.method
- a java.lang.reflect method descriptorMethod
corresponding to the given Java method declaration.public static Method getMethod(java.lang.reflect.Constructor<?> constructor)
Method
.constructor
- a java.lang.reflect constructor descriptorMethod
corresponding to the given Java constructor declaration.public static Method getMethod(java.lang.String method)
Method
corresponding to the given Java method declaration.method
- a Java method declaration, without argument names, of the form "returnType name
(argumentType1, ... argumentTypeN)", where the types are in plain Java (e.g. "int",
"float", "java.util.List", ...). Classes of the java.lang package can be specified by their
unqualified name; all other classes names must be fully qualified.Method
corresponding to the given Java method declaration.java.lang.IllegalArgumentException
- if method
could not get parsed.public static Method getMethod(java.lang.String method, boolean defaultPackage)
Method
corresponding to the given Java method declaration.method
- a Java method declaration, without argument names, of the form "returnType name
(argumentType1, ... argumentTypeN)", where the types are in plain Java (e.g. "int",
"float", "java.util.List", ...). Classes of the java.lang package may be specified by their
unqualified name, depending on the defaultPackage argument; all other classes names must be
fully qualified.defaultPackage
- true if unqualified class names belong to the default package, or false
if they correspond to java.lang classes. For instance "Object" means "Object" if this
option is true, or "java.lang.Object" otherwise.Method
corresponding to the given Java method declaration.java.lang.IllegalArgumentException
- if method
could not get parsed.private static java.lang.String getDescriptor(java.lang.String type, boolean defaultPackage)
type
- a Java type name.defaultPackage
- true if unqualified class names belong to the default package, or false
if they correspond to java.lang classes. For instance "Object" means "Object" if this
option is true, or "java.lang.Object" otherwise.public java.lang.String getName()
public java.lang.String getDescriptor()
public Type getReturnType()
public Type[] getArgumentTypes()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object