Class InvocableMethod

java.lang.Object
com.suncode.pwfl.component.support.InvocableMethod

@Api public class InvocableMethod extends Object
Wrapper around Method that allows to easily invoke method using dynamic ParameterBinder.
Author:
Cezary Kozar 31 maj 2016
  • Constructor Details

    • InvocableMethod

      public InvocableMethod(Method method)
  • Method Details

    • getMethod

      public Method getMethod()
      Returns original method
    • getDeclaringClass

      public Class<?> getDeclaringClass()
      Returns class that declared this method Method.getDeclaringClass()
    • getParameterCount

      public int getParameterCount()
      Returns parameter count
    • getParameterClass

      public Class<?> getParameterClass(int index)
      Returns parameter class by parameter index.
      Parameters:
      index - parameter index
      Returns:
      parameter class
    • getParameterAnnotation

      public Annotation getParameterAnnotation(int index, Class<? extends Annotation> annotationType)
      Returns parameter annotation of given class by parameter index.
      Parameters:
      index - parameter index
      annotationType - annotation class
      Returns:
      annotation or null
    • hasParameterAnnotation

      public boolean hasParameterAnnotation(int index, Class<? extends Annotation> annotationType)
      Returns true if parameter has given annotation.
      Parameters:
      index - parameter index
      annotationType - annotation class
      Returns:
      true if annotation exists
    • getParameterName

      public String getParameterName(int index)
      Returns parameter name. Parameter name is extracted from Param annotation or using StandardReflectionParameterNameDiscoverer.
      Parameters:
      index - parameter index
      Returns:
      parameter name
    • invoke

      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 invoked
      binders - parameter binders
      Returns:
      invocation result
      Throws:
      IllegalAccessException
      IllegalArgumentException
      InvocationTargetException
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object