Class MethodSupport
- java.lang.Object
-
- org.assertj.core.util.introspection.MethodSupport
-
public class MethodSupport extends java.lang.Object
Utility class for reflective method invocation.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
METHOD_HAS_NO_RETURN_VALUE
private static java.lang.String
METHOD_NOT_FOUND
-
Constructor Summary
Constructors Constructor Description MethodSupport()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
assertHasReturnType(java.lang.Class<?> itemClass, java.lang.reflect.Method method)
private static java.lang.reflect.Method
findMethod(java.lang.String methodName, java.lang.Class<?> itemClass)
private static java.lang.Object
invokeMethod(java.lang.Object item, java.lang.reflect.Method method)
static java.lang.Object
methodResultFor(java.lang.Object instance, java.lang.String methodName)
Returns result of given method invocation on provided object.private static java.lang.IllegalArgumentException
prepareMethodNotFoundException(java.lang.String methodName, java.lang.Class<?> itemClass, java.lang.Exception cause)
-
-
-
Field Detail
-
METHOD_HAS_NO_RETURN_VALUE
private static final java.lang.String METHOD_HAS_NO_RETURN_VALUE
- See Also:
- Constant Field Values
-
METHOD_NOT_FOUND
private static final java.lang.String METHOD_NOT_FOUND
- See Also:
- Constant Field Values
-
-
Method Detail
-
methodResultFor
public static java.lang.Object methodResultFor(java.lang.Object instance, java.lang.String methodName)
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:
java.lang.IllegalArgumentException
- if method does not exist or is not public, method returns void or method accepts any argument
-
invokeMethod
private static java.lang.Object invokeMethod(java.lang.Object item, java.lang.reflect.Method method)
-
findMethod
private static java.lang.reflect.Method findMethod(java.lang.String methodName, java.lang.Class<?> itemClass)
-
prepareMethodNotFoundException
private static java.lang.IllegalArgumentException prepareMethodNotFoundException(java.lang.String methodName, java.lang.Class<?> itemClass, java.lang.Exception cause)
-
assertHasReturnType
private static void assertHasReturnType(java.lang.Class<?> itemClass, java.lang.reflect.Method method)
-
-