public class MethodUtils
extends java.lang.Object
Constructor and Description |
---|
MethodUtils()
MethodUtils instances should NOT be constructed in standard programming. |
Modifier and Type | Method and Description |
---|---|
static java.lang.reflect.Method |
getAccessibleMethod(java.lang.reflect.Method method)
Returns an accessible method (that is, one that can be invoked via
reflection) that implements the specified Method.
|
static java.lang.reflect.Method |
getMatchingAccessibleMethod(java.lang.Class<?> cls,
java.lang.String methodName,
java.lang.Class<?>... parameterTypes)
Finds an accessible method that matches the given name and has compatible parameters.
|
public MethodUtils()
MethodUtils
instances should NOT be constructed in standard programming.
Instead, the class should be used as
MethodUtils.getAccessibleMethod(method)
.
This constructor is public
to permit tools that require a JavaBean
instance to operate.
public static java.lang.reflect.Method getAccessibleMethod(java.lang.reflect.Method method)
Returns an accessible method (that is, one that can be invoked via
reflection) that implements the specified Method. If no such method
can be found, return null
.
method
- The method that we wish to callpublic static java.lang.reflect.Method getMatchingAccessibleMethod(java.lang.Class<?> cls, java.lang.String methodName, java.lang.Class<?>... parameterTypes)
Finds an accessible method that matches the given name and has compatible parameters. Compatible parameters mean that every method parameter is assignable from the given parameters. In other words, it finds a method with the given name that will take the parameters given.
This method can match primitive parameter by passing in wrapper classes.
For example, a Boolean
will match a primitive boolean
parameter.
cls
- find method in this classmethodName
- find method with this nameparameterTypes
- find method with most compatible parameters