public class MethodKit extends Object
| 构造器和说明 |
|---|
MethodKit() |
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
existSpecifiedMethod(Class<?> aClass,
String name,
Class<?>[] parameterTypes)
对象是否存在指定方法
|
static Object |
invokeExactMethod(Object object,
String methodName,
Object[] args,
Class<?>[] parameterTypes)
执行目标方法
|
static Object |
invokeExactMethodNotException(Object object,
String methodName,
Object... args)
执行目标方法 , 不抛出异常,如果发生异常则返回null,且打印错误信息
|
public static boolean existSpecifiedMethod(Class<?> aClass, String name, Class<?>[] parameterTypes)
aClass - 对象类型name - 方法名称parameterTypes - 方法参数类型public static Object invokeExactMethod(Object object, String methodName, Object[] args, Class<?>[] parameterTypes) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
object - 目标对象methodName - 目标方法args - 方法参数NoSuchMethodException - 没有这样的方法例外IllegalAccessException - 非法访问例外InvocationTargetException - 调用方法执行异常Copyright © 2019. All rights reserved.