接口 MethodUtils
-
public interface MethodUtils
Miscellaneous method utility methods. Mainly for internal use within the framework.- 从以下版本开始:
- 2.7.2
-
-
方法概要
静态方法 修饰符和类型 方法 说明 static Predicate<Method>
excludedDeclaredClass(Class<?> declaredClass)
static Method
findMethod(Class type, String methodName)
Find theMethod
by the the specified type and method name without the parameter typesstatic Method
findMethod(Class type, String methodName, Class<?>... parameterTypes)
Find theMethod
by the the specified type, method name and parameter typesstatic Method
findNearestOverriddenMethod(Method overrider)
Find the nearest overriddenmethod
from the inherited classstatic Method
findOverriddenMethod(Method overrider, Class<?> declaringClass)
Find the overriddenmethod
from the declaring classstatic List<Method>
getAllDeclaredMethods(Class<?> declaringClass, Predicate<Method>... methodsToFilter)
Get all declaredmethods
of the declared class, including the inherited methods.static List<Method>
getAllMethods(Class<?> declaringClass, Predicate<Method>... methodsToFilter)
Get all publicmethods
of the declared class, including the inherited methods.static List<Method>
getDeclaredMethods(Class<?> declaringClass, Predicate<Method>... methodsToFilter)
Get all declaredmethods
of the declared class, excluding the inherited methodsstatic List<Method>
getMethods(Class<?> declaringClass, boolean includeInheritedTypes, boolean publicOnly, Predicate<Method>... methodsToFilter)
Get allmethods
of the declared classstatic List<Method>
getMethods(Class<?> declaringClass, Predicate<Method>... methodsToFilter)
Get all publicmethods
of the declared class, including the inherited methods.static <T> T
invokeMethod(Object object, String methodName, Object... methodParameters)
Invoke the target object and methodstatic boolean
isDeprecated(Method method)
Check if the method is a deprecated method.static boolean
isGetter(Method method)
Returntrue
if the provided method is a get method.static boolean
isMetaMethod(Method method)
Returntrue
If this method is a meta method.static boolean
isSetter(Method method)
Returntrue
if the provided method is a set method.static boolean
overrides(Method overrider, Method overridden)
Tests whether one method, as a member of a given type, overrides another method.
-
-
-
方法详细资料
-
isSetter
static boolean isSetter(Method method)
Returntrue
if 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)
Returntrue
if 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)
Returntrue
If 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 theDeprecated
annotation is declared on the class. Returntrue
if 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 allmethods
of 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 declaredmethods
of 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 publicmethods
of 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 declaredmethods
of 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 publicmethods
of 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 theMethod
by 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 theMethod
by 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- 返回:
true
if and only if the first method overrides the second- 另请参阅:
Elements.overrides(ExecutableElement, ExecutableElement, TypeElement)
-
findNearestOverriddenMethod
static Method findNearestOverriddenMethod(Method overrider)
Find the nearest overriddenmethod
from the inherited class- 参数:
overrider
- the overridermethod
- 返回:
- if found, the overrider
method
, ornull
-
-