Class MethodUtils


  • public class MethodUtils
    extends Object
    Imported from apache.commons.lang3 3.6
    • Constructor Detail

      • MethodUtils

        public MethodUtils()
        MethodUtils instances should NOT be constructed in standard programming. Instead, the class should be used as MethodUtils.getAccessibleMethod(method).

        This constructor is public to permit tools that require a JavaBean instance to operate.

    • Method Detail

      • getAccessibleMethod

        public static Method getAccessibleMethod​(Method method)
        Returns an accessible method (that is, one that can be invoked via reflection) that implements the specified Method. If no such method can be found, return null.
        Parameters:
        method - The method that we wish to call
        Returns:
        The accessible method
      • getMatchingAccessibleMethod

        public static Method getMatchingAccessibleMethod​(Class<?> cls,
                                                         String methodName,
                                                         Class<?>... parameterTypes)
        Finds an accessible method that matches the given name and has compatible parameters. Compatible parameters mean that every method parameter is assignable from the given parameters. In other words, it finds a method with the given name that will take the parameters given.

        This method can match primitive parameter by passing in wrapper classes. For example, a Boolean will match a primitive boolean parameter.

        Parameters:
        cls - find method in this class
        methodName - find method with this name
        parameterTypes - find method with most compatible parameters
        Returns:
        The accessible method