Class InvocableMethod
java.lang.Object
com.suncode.pwfl.component.support.InvocableMethod
Wrapper around Method that allows to easily invoke method using
dynamic
ParameterBinder
.- Author:
- Cezary Kozar 31 maj 2016
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionClass<?>
Returns class that declared this methodMethod.getDeclaringClass()
Returns original methodgetParameterAnnotation
(int index, Class<? extends Annotation> annotationType) Returns parameter annotation of given class by parameter index.Class<?>
getParameterClass
(int index) Returns parameter class by parameter index.int
Returns parameter countgetParameterName
(int index) Returns parameter name.boolean
hasParameterAnnotation
(int index, Class<? extends Annotation> annotationType) Returns true if parameter has given annotation.invoke
(Object instance, ParameterBinder... binders) Invokes this method on given instance (may be null for static methods).toString()
-
Constructor Details
-
InvocableMethod
-
-
Method Details
-
getMethod
Returns original method -
getDeclaringClass
Returns class that declared this methodMethod.getDeclaringClass()
-
getParameterCount
public int getParameterCount()Returns parameter count -
getParameterClass
Returns parameter class by parameter index.- Parameters:
index
- parameter index- Returns:
- parameter class
-
getParameterAnnotation
Returns parameter annotation of given class by parameter index.- Parameters:
index
- parameter indexannotationType
- annotation class- Returns:
- annotation or null
-
hasParameterAnnotation
Returns true if parameter has given annotation.- Parameters:
index
- parameter indexannotationType
- annotation class- Returns:
- true if annotation exists
-
getParameterName
Returns parameter name. Parameter name is extracted fromParam
annotation or usingStandardReflectionParameterNameDiscoverer
.- Parameters:
index
- parameter index- Returns:
- parameter name
-
invoke
public Object invoke(Object instance, ParameterBinder... binders) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException Invokes this method on given instance (may be null for static methods). Provided binders are used to bind every method parameter. If single method parameter cannot be binded then IllegalArgumentException is thrown.Binders are invoked in specified order.
- Parameters:
instance
- instance on which method will be invokedbinders
- parameter binders- Returns:
- invocation result
- Throws:
IllegalAccessException
IllegalArgumentException
InvocationTargetException
- See Also:
-
toString
-