接口 MethodUtils


  • public interface MethodUtils
    Miscellaneous method utility methods. Mainly for internal use within the framework.
    从以下版本开始:
    2.7.2
    • 方法详细资料

      • isSetter

        static boolean isSetter​(Method method)
        Return true if the provided method is a set method. Otherwise, return false.
        参数:
        method - the method to check
        返回:
        whether the given method is setter method
      • isGetter

        static boolean isGetter​(Method method)
        Return true if the provided method is a get method. Otherwise, return false.
        参数:
        method - the method to check
        返回:
        whether the given method is getter method
      • isMetaMethod

        static boolean isMetaMethod​(Method method)
        Return true If this method is a meta method. Otherwise, return false.
        参数:
        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 the Deprecated annotation is declared on the class. Return true if this annotation is present. Otherwise, return false.
        参数:
        method - the method to check
        返回:
        whether the given method is deprecated method
      • excludedDeclaredClass

        static Predicate<Method> excludedDeclaredClass​(Class<?> declaredClass)
        Create an instance of Predicate for Method to exclude the specified declared class
        参数:
        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 all methods of the declared class
        参数:
        declaringClass - the declared class
        includeInheritedTypes - include the inherited types, e,g. super classes or interfaces
        publicOnly - only public method
        methodsToFilter - (optional) the methods to be filtered
        返回:
        non-null read-only List
        从以下版本开始:
        2.7.6
      • findMethod

        static Method findMethod​(Class type,
                                 String methodName)
        Find the Method by the the specified type and method name without the parameter types
        参数:
        type - the target type
        methodName - the specified method name
        返回:
        if not found, return null
        从以下版本开始:
        2.7.6
      • findMethod

        static Method findMethod​(Class type,
                                 String methodName,
                                 Class<?>... parameterTypes)
        Find the Method by the the specified type, method name and parameter types
        参数:
        type - the target type
        methodName - the method name
        parameterTypes - 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 object
        methodName - the method name
        methodParameters - 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 overrider
        overridden - 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 overridden method from the inherited class
        参数:
        overrider - the overrider method
        返回:
        if found, the overrider method, or null
      • findOverriddenMethod

        static Method findOverriddenMethod​(Method overrider,
                                           Class<?> declaringClass)
        Find the overridden method from the declaring class
        参数:
        overrider - the overrider method
        declaringClass - the class that is declaring the overridden method
        返回:
        if found, the overrider method, or null