接口 MethodUtils
-
public interface MethodUtilsMiscellaneous method utility methods. Mainly for internal use within the framework.- 从以下版本开始:
- 2.7.2
-
-
方法概要
静态方法 修饰符和类型 方法 说明 static Predicate<Method>excludedDeclaredClass(Class<?> declaredClass)static MethodfindMethod(Class type, String methodName)Find theMethodby the the specified type and method name without the parameter typesstatic MethodfindMethod(Class type, String methodName, Class<?>... parameterTypes)Find theMethodby the the specified type, method name and parameter typesstatic MethodfindNearestOverriddenMethod(Method overrider)Find the nearest overriddenmethodfrom the inherited classstatic MethodfindOverriddenMethod(Method overrider, Class<?> declaringClass)Find the overriddenmethodfrom the declaring classstatic List<Method>getAllDeclaredMethods(Class<?> declaringClass, Predicate<Method>... methodsToFilter)Get all declaredmethodsof the declared class, including the inherited methods.static List<Method>getAllMethods(Class<?> declaringClass, Predicate<Method>... methodsToFilter)Get all publicmethodsof the declared class, including the inherited methods.static List<Method>getDeclaredMethods(Class<?> declaringClass, Predicate<Method>... methodsToFilter)Get all declaredmethodsof the declared class, excluding the inherited methodsstatic List<Method>getMethods(Class<?> declaringClass, boolean includeInheritedTypes, boolean publicOnly, Predicate<Method>... methodsToFilter)Get allmethodsof the declared classstatic List<Method>getMethods(Class<?> declaringClass, Predicate<Method>... methodsToFilter)Get all publicmethodsof the declared class, including the inherited methods.static <T> TinvokeMethod(Object object, String methodName, Object... methodParameters)Invoke the target object and methodstatic booleanisDeprecated(Method method)Check if the method is a deprecated method.static booleanisGetter(Method method)Returntrueif the provided method is a get method.static booleanisMetaMethod(Method method)ReturntrueIf this method is a meta method.static booleanisSetter(Method method)Returntrueif the provided method is a set method.static booleanoverrides(Method overrider, Method overridden)Tests whether one method, as a member of a given type, overrides another method.
-
-
-
方法详细资料
-
isSetter
static boolean isSetter(Method method)
Returntrueif the provided method is a set method. Otherwise, returnfalse.- 参数:
method- the method to check- 返回:
- whether the given method is setter method
-
isGetter
static boolean isGetter(Method method)
Returntrueif the provided method is a get method. Otherwise, returnfalse.- 参数:
method- the method to check- 返回:
- whether the given method is getter method
-
isMetaMethod
static boolean isMetaMethod(Method method)
ReturntrueIf this method is a meta method. Otherwise, returnfalse.- 参数:
method- the method to check- 返回:
- whether the given method is meta method
-
isDeprecated
static boolean isDeprecated(Method method)
Check if the method is a deprecated method. The standard is whether theDeprecatedannotation is declared on the class. Returntrueif this annotation is present. Otherwise, returnfalse.- 参数:
method- the method to check- 返回:
- whether the given method is deprecated method
-
excludedDeclaredClass
static Predicate<Method> excludedDeclaredClass(Class<?> declaredClass)
- 参数:
declaredClass- the declared class to exclude- 返回:
- non-null
- 从以下版本开始:
- 2.7.6
-
getMethods
static List<Method> getMethods(Class<?> declaringClass, boolean includeInheritedTypes, boolean publicOnly, Predicate<Method>... methodsToFilter)
Get allmethodsof the declared class- 参数:
declaringClass- the declared classincludeInheritedTypes- include the inherited types, e,g. super classes or interfacespublicOnly- only public methodmethodsToFilter- (optional) the methods to be filtered- 返回:
- non-null read-only
List - 从以下版本开始:
- 2.7.6
-
getDeclaredMethods
static List<Method> getDeclaredMethods(Class<?> declaringClass, Predicate<Method>... methodsToFilter)
Get all declaredmethodsof the declared class, excluding the inherited methods- 参数:
declaringClass- the declared classmethodsToFilter- (optional) the methods to be filtered- 返回:
- non-null read-only
List - 从以下版本开始:
- 2.7.6
- 另请参阅:
getMethods(Class, boolean, boolean, Predicate[])
-
getMethods
static List<Method> getMethods(Class<?> declaringClass, Predicate<Method>... methodsToFilter)
Get all publicmethodsof the declared class, including the inherited methods.- 参数:
declaringClass- the declared classmethodsToFilter- (optional) the methods to be filtered- 返回:
- non-null read-only
List - 从以下版本开始:
- 2.7.6
- 另请参阅:
getMethods(Class, boolean, boolean, Predicate[])
-
getAllDeclaredMethods
static List<Method> getAllDeclaredMethods(Class<?> declaringClass, Predicate<Method>... methodsToFilter)
Get all declaredmethodsof the declared class, including the inherited methods.- 参数:
declaringClass- the declared classmethodsToFilter- (optional) the methods to be filtered- 返回:
- non-null read-only
List - 从以下版本开始:
- 2.7.6
- 另请参阅:
getMethods(Class, boolean, boolean, Predicate[])
-
getAllMethods
static List<Method> getAllMethods(Class<?> declaringClass, Predicate<Method>... methodsToFilter)
Get all publicmethodsof the declared class, including the inherited methods.- 参数:
declaringClass- the declared classmethodsToFilter- (optional) the methods to be filtered- 返回:
- non-null read-only
List - 从以下版本开始:
- 2.7.6
- 另请参阅:
getMethods(Class, boolean, boolean, Predicate[])
-
findMethod
static Method findMethod(Class type, String methodName)
Find theMethodby the the specified type and method name without the parameter types- 参数:
type- the target typemethodName- the specified method name- 返回:
- if not found, return
null - 从以下版本开始:
- 2.7.6
-
findMethod
static Method findMethod(Class type, String methodName, Class<?>... parameterTypes)
Find theMethodby the the specified type, method name and parameter types- 参数:
type- the target typemethodName- the method nameparameterTypes- the parameter types- 返回:
- if not found, return
null - 从以下版本开始:
- 2.7.6
-
invokeMethod
static <T> T invokeMethod(Object object, String methodName, Object... methodParameters)
Invoke the target object and method- 类型参数:
T- the return type- 参数:
object- the target objectmethodName- the method namemethodParameters- the method parameters- 返回:
- the target method's execution result
- 从以下版本开始:
- 2.7.6
-
overrides
static boolean overrides(Method overrider, Method overridden)
Tests whether one method, as a member of a given type, overrides another method.- 参数:
overrider- the first method, possible overrideroverridden- the second method, possibly being overridden- 返回:
trueif and only if the first method overrides the second- 另请参阅:
Elements.overrides(ExecutableElement, ExecutableElement, TypeElement)
-
findNearestOverriddenMethod
static Method findNearestOverriddenMethod(Method overrider)
Find the nearest overriddenmethodfrom the inherited class- 参数:
overrider- the overridermethod- 返回:
- if found, the overrider
method, ornull
-
-