public class MethodUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
MethodUtil.MethodUtilException
此工具类的异常
|
Constructor and Description |
---|
MethodUtil() |
Modifier and Type | Method and Description |
---|---|
static Object |
eval(String str)
js中的eval函数,应该是只能进行简单的计算
利用js脚本完成
|
static <T> Method |
getMethod(Class<T> type,
String methodName)
获取方法
|
static <T> Method |
getMethod(T type,
String methodName)
获取方法
|
static Method[] |
getMethods(Class clazz)
获取全部方法,默认排除Object中继承来的方法
|
static Method[] |
getMethods(Class clazz,
Predicate<Method> filter)
获取全部方法,默认排除Object中继承来的方法
|
static Method[] |
getMethods(Class clazz,
Predicate<Method> filter,
boolean withoutObjMe)
获取全部方法
|
static List<Method> |
getOriginal(List<Method> methods)
Filter out the Object Methods
过滤掉Object中继承来的方法 |
static Method[] |
getPublicMethods(Class clazz)
获取全部公共方法,默认排除Object继承来的方法
|
static Method[] |
getPublicMethods(Class clazz,
Predicate<Method> filter)
获取全部公共方法,默认排除Object继承来的方法
|
static Method[] |
getPublicMethods(Class clazz,
Predicate<Method> filter,
boolean withoutObjMe)
获取全部公共方法
|
static Object |
invoke(Object obj,
Object[] args,
Method method)
执行一个方法,可以为基本的数据类型进行转化
|
static Object |
invoke(Object obj,
Object[] args,
String methodName)
执行一个方法,可以为基本的数据类型进行转化
|
static boolean |
isStatic(Method method)
判断方法是否为静态方法
|
public static Object invoke(Object obj, Object[] args, Method method) throws InvocationTargetException, IllegalAccessException
obj
- args
- method
- InvocationTargetException
IllegalAccessException
public static Object invoke(Object obj, Object[] args, String methodName) throws NoSuchMethodException
obj
- args
- methodName
- 方法名NoSuchMethodException
public static List<Method> getOriginal(List<Method> methods)
methods
- 需要过滤的方法列表public static Object eval(String str) throws ScriptException
str
- 需要进行eval执行的函数ScriptException
public static Method[] getMethods(Class clazz, Predicate<Method> filter, boolean withoutObjMe)
clazz
- clazz对象withoutObjMe
- 是否排除Object中继承来的方法public static Method[] getMethods(Class clazz, Predicate<Method> filter)
clazz
- clazz对象public static Method[] getMethods(Class clazz)
clazz
- clazz对象public static Method[] getPublicMethods(Class clazz, Predicate<Method> filter, boolean withoutObjMe)
clazz
- clazz对象withoutObjMe
- 是否排除Object中继承来的方法public static Method[] getPublicMethods(Class clazz, Predicate<Method> filter)
clazz
- clazz对象public static Method[] getPublicMethods(Class clazz)
clazz
- clazz对象public static boolean isStatic(Method method)
method
- 方法对象public static <T> Method getMethod(Class<T> type, String methodName) throws NoSuchMethodException
type
- 类型methodName
- 方法名NoSuchMethodException
public static <T> Method getMethod(T type, String methodName) throws NoSuchMethodException
type
- 类型methodName
- 方法名NoSuchMethodException
Copyright © 2020. All rights reserved.