Methods, originally from Commons BeanUtils.
Differences from the BeanUtils version may be noted, especially where similar functionality
already existed within Lang.
There is an issue when invoking public methods contained in a default access superclass on JREs prior to 1.4.
Reflection locates these methods fine and correctly assigns them as public.
However, an IllegalAccessException is thrown if the method is invoked.
MethodUtils contains a workaround for this situation.
It will attempt to call java. on this method.
If this call succeeds, then the method can be invoked as normal.
This call will only succeed when the application has sufficient security privileges.
If this call fails then the method may fail.
| Modifier and Type | Field and Description |
|---|---|
| private static final Comparator |
| Access | Constructor and Description |
|---|---|
| public | MethodUtils()
Deprecated
TODO Make private in 4.0.
|
| Modifier and Type | Method and Description |
|---|---|
| private static int | Returns: the aggregate number of inheritance hops between assignable argument class types.the Class array to calculate the distance from. fromClassArray, final Class<?>[] the Class array to calculate the distance to. toClassArray)Computes the aggregate number of inheritance hops between assignable argument class types. |
| public static Method | Returns: The accessible method or null.The implementing class, may be null. cls, final Method The method that we wish to call, may be null. method)Gets an accessible method (that is, one that can be invoked via reflection) that implements the specified Method. |
| public static Method | Returns: The accessible method.get method from this class. cls, final String get method with this name. methodName, final Class<?>... with these parameters types. parameterTypes)Gets an accessible method (that is, one that can be invoked via reflection) with given name and parameters. |
| public static Method | Returns: The accessible methodThe method that we wish to call, may be null. method)Gets an accessible method (that is, one that can be invoked via reflection) that implements the specified Method. |
| private static Method | Returns: the accessible method ornull if not found.Parent class for the interfaces to be checked. cls, final String Method name of the method we wish to call. methodName, final Class<?>... The parameter type signatures. parameterTypes)Gets an accessible method (that is, one that can be invoked via reflection) that implements the specified method, by scanning through all implemented interfaces and subinterfaces. |
| private static Method | Returns: the accessible method ornull if not found.Class to be checked. cls, final String Method name of the method we wish to call. methodName, final Class<?>... The parameter type signatures. parameterTypes)Gets an accessible method (that is, one that can be invoked via reflection) by scanning through the superclasses. |
| private static List | Returns: the combinedList of superclasses and interfaces in order going up from this one null if null input.the class to look up, may be cls)null.Gets a combination of |
| public static < the annotation type. A extends Annotation> A | Returns: the first matching annotation, ornull if not found.the method, final Class<A> Method to query, may be null.the annotationCls, final boolean Annotation to check if is present on the method.determines if a lookup in the entire inheritance hierarchy of the given class is performed if the annotation was not directly
present. searchSupers, final boolean determines if underlying method has to be accessible. ignoreAccess)Gets the annotation object with the given annotation type that is present on the given method or optionally on any equivalent method in super classes and interfaces. |
| private static Method | getInvokeMethod(final boolean forceAccess, final String methodName, final Class<?>[] parameterTypes, final Class<? extends Object> cls)
|
| public static Method | Returns: The accessible method or null.find method in this class. cls, final String find method with this name. methodName, final Class<?>... find method with most compatible parameters. requestTypes)Gets an accessible method that matches the given name and has compatible parameters. |
| public static Method | Returns: The method.The class that will be subjected to the method search. cls, final String The method that we wish to call. methodName, final Class<?>... Argument class types. parameterTypes)Gets a method whether or not it's accessible. |
| public static Method | Returns: a Method ornull.Receiver for cls, final String Class#getMethod(String, Class..the name of the method. name, final Class<?>... the list of parameters. parameterTypes)Gets a Method, or |
| public static List | Returns: a list of Methods (possibly empty).the cls, final Class<? extends Annotation> Class to query.the annotationCls)Annotation that must be present on a method to be matched.Gets all class level public methods of the given class that are annotated with the given annotation. |
| public static List | Returns: a list of Methods (possibly empty).the cls, final Class<? extends Annotation> Class to query.the annotationCls, final boolean Annotation that must be present on a method to be matched.determines if a lookup in the entire inheritance hierarchy of the given class should be performed. searchSupers, final boolean determines if non-public methods should be considered. ignoreAccess)Gets all methods of the given class that are annotated with the given annotation. |
| public static Method[] | Returns: an array of Methods (possibly empty).the cls, final Class<? extends Annotation> Class to query.the annotationCls)java. that must be present on a method to be matched.Gets all class level public methods of the given class that are annotated with the given annotation. |
| public static Method[] | Returns: an array of Methods (possibly empty).the cls, final Class<? extends Annotation> Class to query.the annotationCls, final boolean java. that must be present on a method to be matched.determines if a lookup in the entire inheritance hierarchy of the given class should be performed. searchSupers, final boolean determines if non-public methods should be considered. ignoreAccess)Gets all methods of the given class that are annotated with the given annotation. |
| public static Set | Returns: aSet<Method> in ascending order from subclass to superclass.lowest to consider. method, final ClassUtils.whether to search interfaces, interfacesBehaviornull implies false.Gets the hierarchy of overridden methods down to |
| public static Object | Returns: The value returned by the invoked method.invoke method on this object. object, final String get method with this name. methodName)Invokes a method whose parameter types match exactly the object type. |
| public static Object | Returns: The value returned by the invoked method.invoke method on this object. object, final String get method with this name. methodName, final Object... use these arguments - treat null as empty array. args)Invokes a method whose parameter types match exactly the object types. |
| public static Object | Returns: The value returned by the invoked method.Invokes a method on this object. object, final String Gets a method with this name. methodName, final Object[] Method arguments - treat null as empty array. args, final Class<?>[] Match these parameters - treat parameterTypes)null as empty array.Invokes a method whose parameter types match exactly the parameter types given. |
| public static Object | Returns: The value returned by the invoked method.invoke static method on this class. cls, final String get method with this name. methodName, final Object... use these arguments - treat args)null as empty array.Invokes a |
| public static Object | Returns: The value returned by the invoked method.invoke static method on this class. cls, final String get method with this name. methodName, final Object[] use these arguments - treat args, final Class<?>[] null as empty array.match these parameters - treat parameterTypes)null as empty array.Invokes a |
| public static Object | Returns: The value returned by the invoked method.invoke method on this object. object, final boolean force access to invoke method even if it's not accessible. forceAccess, final String get method with this name. methodName)Invokes a named method without parameters. |
| public static Object | Returns: The value returned by the invoked method.invoke method on this object. object, final boolean force access to invoke method even if it's not accessible. forceAccess, final String get method with this name. methodName, final Object... use these arguments - treat null as empty array. args)Invokes a named method whose parameter type matches the object type. |
| public static Object | Returns: The value returned by the invoked method.invoke method on this object. object, final boolean force access to invoke method even if it's not accessible. forceAccess, final String get method with this name. methodName, final Object[] use these arguments - treat null as empty array. args, final Class<?>[] match these parameters - treat null as empty array. parameterTypes)Invokes a named method whose parameter type matches the object type. |
| public static Object | Returns: The value returned by the invoked method.invoke method on this object. object, final String get method with this name. methodName)Invokes a named method without parameters. |
| public static Object | Returns: The value returned by the invoked method.invoke method on this object. object, final String get method with this name. methodName, final Object... use these arguments - treat null as empty array. args)Invokes a named method whose parameter type matches the object type. |
| public static Object | Returns: The value returned by the invoked method.invoke method on this object. object, final String get method with this name. methodName, final Object[] use these arguments - treat null as empty array. args, final Class<?>[] match these parameters - treat null as empty array. parameterTypes)Invokes a named method whose parameter type matches the object type. |
| public static Object | Returns: The value returned by the invoked method.invoke static method on this class. cls, final String get method with this name. methodName, final Object... use these arguments - treat args)null as empty array.Invokes a named |
| public static Object | Returns: The value returned by the invoked method.invoke static method on this class. cls, final String get method with this name. methodName, final Object[] use these arguments - treat args, final Class<?>[] null as empty array.match these parameters - treat parameterTypes)null as empty array.Invokes a named |
| private static Method | requireNonNull(final Method method, final Class<?> cls, final String methodName, final Class<?>[] parameterTypes)
|
| pack-priv static Object[] | |
| private static Object[] | Returns: an array of the variadic arguments passed to the method.the array of arguments passed to the varags method. args, final Class<?>[] the declared array of method parameter types. methodParameterTypes)Gets an array of arguments in the canonical form, given an arguments array passed to a varargs method, for example an array with the declared number of parameters, and whose last parameter is an array of the varargs type. |