public class MethodUtil extends Object
| Constructor and Description |
|---|
MethodUtil() |
| Modifier and Type | Method and Description |
|---|---|
static Method |
getMethodByName(Class<?> targetClazz,
String methodName)
通过方法名获取对应的方法,如果有重载方法,会抛出UnsupportedOperationException
|
static Method |
getMethodByNameAndTypes(Class<?> targetClazz,
String methodName,
String[] argsType)
通过方法名、参数类型获取对应的方法
|
static List<Method> |
getMethodsStartWithNamePattern(Class<?> targetClazz,
String methodNamePattern)
通过方法名的起始字符来获取所有重载、类似的方法,不支持通配
|
public static Method getMethodByName(Class<?> targetClazz, String methodName) throws NoSuchMethodException
targetClazz - methodName - NoSuchMethodExceptionpublic static Method getMethodByNameAndTypes(Class<?> targetClazz, String methodName, String[] argsType) throws NoSuchMethodException
targetClazz - methodName - argsType - 无参请写new String[0]NoSuchMethodExceptionpublic static List<Method> getMethodsStartWithNamePattern(Class<?> targetClazz, String methodNamePattern) throws NoSuchMethodException
targetClazz - methodNamePattern - NoSuchMethodExceptionCopyright © 2017. All rights reserved.