Package org.apache.tapestry5.plastic

# Interface MethodInvocation

All Superinterfaces:
  `AnnotationAccess`, `MethodInvocationResult`

All Known Implementing Classes:
  `AbstractMethodInvocation`

public interface MethodInvocation extends MethodInvocationResult, AnnotationAccess
A representation of the invocation of a method that allows the behavior of the method to be advised: either by changing parameter values, or by changing the return value, or by catch or throwing different exceptions. Provides access to annotations on the advised method.

See Also:
  - `MethodAdvice`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `getInstance()`
  The instance on which the method was originally invoked.
  `InstanceContext`
  `getInstanceContext()`
  `Method`
  `getMethod()`
  Returns the method being invoked.
  `Object`
  `getParameter(int index)`
  Returns the parameter at the given index.
  `MethodInvocation`
  `proceed()`
  Proceed with the method invocation, either chaining into the next `MethodAdvice` added to the method, or ultimately into the actual method implementation.
  `MethodInvocation`
  `setCheckedException(Exception exception)`
  Sets the checked exception; this can be used to indicate failure for the method, or to cancel the thrown exception (by setting the exception to null).
  `MethodInvocation`
  `setParameter(int index, Object newValue)`
  Changes a parameter value.
  `MethodInvocation`
  `setReturnValue(Object returnValue)`
  Overrides the return value of the method.

  ### Methods inherited from interface org.apache.tapestry5.plastic.AnnotationAccess

  `getAnnotation, hasAnnotation`

  ### Methods inherited from interface org.apache.tapestry5.plastic.MethodInvocationResult

  `didThrowCheckedException, getCheckedException, getReturnValue, rethrow`

- ## Method Details

  - ### getInstance

    Object getInstance()
    The instance on which the method was originally invoked.

  - ### getInstanceContext

    InstanceContext getInstanceContext()

  - ### proceed

    MethodInvocation proceed()
    Proceed with the method invocation, either chaining into the next `MethodAdvice` added to the method, or ultimately into the actual method implementation. The method may throw a checked exception, which will be caught and be reported as `MethodInvocationResult.didThrowCheckedException()`.
    Returns:
      this method invocation, for a fluent API

  - ### setReturnValue

    MethodInvocation setReturnValue(Object returnValue)
    Overrides the return value of the method. The value provided will be cast to the actual return type (or, if the return type is a primitive value, the value will be cast to the corresponding wrapper type and then converted to a primitive). Overriding the return value clears any checked exception.
    Parameters:
      `returnValue` -
    Returns:
      this method invocation, for a fluent API
    Throws:
      `NullPointerException` - if the method's return type is a primitive and null is provided

  - ### getParameter

    Object getParameter(int index)
    Returns the parameter at the given index. Primitive types will be wrapped as they are returned.
    Parameters:
      `index` - of parameter to access
    Returns:
      parameter value

  - ### setParameter

    MethodInvocation setParameter(int index, Object newValue)
    Changes a parameter value. The value will be cast to the parameter's type. For primitive types, the value will be cast to the corresponding wrapper type.
    Parameters:
      `index` - index of parameter to modify
      `newValue` - new value for parameter
    Returns:
      this method invocation, for a fluent API

  - ### setCheckedException

    MethodInvocation setCheckedException(Exception exception)
    Sets the checked exception; this can be used to indicate failure for the method, or to cancel the thrown exception (by setting the exception to null).
    Parameters:
      `exception` - new checked exception, or null
    Returns:
      this method invocation, for a fluent API

  - ### getMethod

    Method getMethod()
    Returns the method being invoked.