|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectorg.test4j.tools.commons.MethodHelper
public final class MethodHelper
| 构造方法摘要 | |
|---|---|
MethodHelper()
|
|
| 方法摘要 | ||
|---|---|---|
static
|
findMethodByArgCount(Class targetClazz,
String methodName,
int args)
根据方法的名称和参数个数查找方法访问器,如果有多于1个同名且参数个数一样的方法,那么抛出异常 |
|
static
|
findMethodByArgCount(Object target,
String methodName,
int args)
根据方法的名称和参数个数查找方法访问器,如果有多于1个同名且参数个数一样的方法,那么抛出异常 |
|
static Set<Method> |
getAllMethods(Class clazz)
Gets all methods of the given class and all its super-classes. |
|
static Method |
getMethod(Class cls,
String name,
Class... parametersType)
返回class中名称为name,参数类型为 parametersType的方法 |
|
static List<Method> |
getMethod(Class cls,
String name,
int args)
查找名为name,参数个数为args的方法列表 |
|
static Class[] |
getParameterClazz(Object... paras)
|
|
static Set<Method> |
getSettersAssignableFrom(Class clazz,
Type type,
boolean isStatic)
Returns all declared setter methods of fields of the given class that are assignable from the given type. |
|
static Set<Method> |
getSettersOfType(Class clazz,
Type type)
Returns the setter methods in the given class that have an argument with the exact given type. |
|
static
|
invoke(Object target,
String method,
Object... paras)
调用类为clazz,名称为method的方法 |
|
static
|
invokeStatic(Class targetClass,
String method,
Object... paras)
调用静态方法 |
|
static
|
invokeUnThrow(Object target,
String method,
Object... paras)
|
|
static boolean |
isCloneMethod(Method method)
|
|
static boolean |
isEqualsMethod(Method method)
|
|
static boolean |
isFinalizeMethod(Method method)
|
|
static boolean |
isHashCodeMethod(Method method)
|
|
static boolean |
isPublicStaticVoid(Method method)
测试类是否是 public static void且是无参形式的? |
|
static boolean |
isSetterMethod(Method method)
判断方法是否是setter方法 For each method, check if it can be a setter for an object of the given type. |
|
static boolean |
isToStringMethod(Method method)
|
|
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 构造方法详细信息 |
|---|
public MethodHelper()
| 方法详细信息 |
|---|
public static final Method getMethod(Class cls,
String name,
Class... parametersType)
cls - name - parametersType -
public static final List<Method> getMethod(Class cls,
String name,
int args)
cls - name - args -
public static Set<Method> getSettersAssignableFrom(Class clazz,
Type type,
boolean isStatic)
clazz - The class to get setters from, not nulltype - The type, not nullisStatic - True if static setters are to be returned, false for
non-static
public static Set<Method> getAllMethods(Class clazz)
clazz - The class
public static Set<Method> getSettersOfType(Class clazz,
Type type)
clazz - The class to get the setter from, not nulltype - The type, not nullisStatic - True if static setters are to be returned, false for
non-static
public static boolean isEqualsMethod(Method method)
method - The method to check, not null
Object.equals(java.lang.Object) methodpublic static boolean isHashCodeMethod(Method method)
method - The method to check, not null
Object.hashCode() methodpublic static boolean isToStringMethod(Method method)
method - The method to check, not null
Object.toString() methodpublic static boolean isCloneMethod(Method method)
method - The method to check, not null
Object.clone() methodpublic static boolean isFinalizeMethod(Method method)
public static boolean isSetterMethod(Method method)
method - The method to check, not null
public static <T> T invoke(Object target,
String method,
Object... paras)
throws Exception
methodName - paras -
Exception
public static <T> T invokeUnThrow(Object target,
String method,
Object... paras)
public static Class[] getParameterClazz(Object... paras)
public static <T> T invokeStatic(Class targetClass,
String method,
Object... paras)
T - targetClass - method - paras -
public static <T> MethodAccessor<T> findMethodByArgCount(Class targetClazz,
String methodName,
int args)
target - methodName - args -
public static <T> MethodAccessor<T> findMethodByArgCount(Object target,
String methodName,
int args)
T - target - methodName - args -
public static boolean isPublicStaticVoid(Method method)
method -
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||