Class MethodSupport
java.lang.Object
org.assertj.core.util.introspection.MethodSupport
Utility class for reflective method invocation.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
assertHasReturnType
(Class<?> itemClass, Method method) private static Method
findMethod
(String methodName, Class<?> itemClass) private static Object
invokeMethod
(Object item, Method method) static Object
methodResultFor
(Object instance, String methodName) Returns result of given method invocation on provided object.private static IllegalArgumentException
prepareMethodNotFoundException
(String methodName, Class<?> itemClass, Exception cause)
-
Field Details
-
METHOD_HAS_NO_RETURN_VALUE
- See Also:
-
METHOD_NOT_FOUND
- See Also:
-
-
Constructor Details
-
MethodSupport
public MethodSupport()
-
-
Method Details
-
methodResultFor
Returns result of given method invocation on provided object.Following requirements have to be met to extract method results:
- method has to be public,
- method cannot accept any arguments,
- method cannot return void.
- Parameters:
instance
- object on whichmethodName
- name of method to be invoked- Returns:
- result of method invocation
- Throws:
IllegalArgumentException
- if method does not exist or is not public, method returns void or method accepts any argument
-
invokeMethod
-
findMethod
-
prepareMethodNotFoundException
private static IllegalArgumentException prepareMethodNotFoundException(String methodName, Class<?> itemClass, Exception cause) -
assertHasReturnType
-