com.versionone.utils

## Class Delegator.DelegateProxy

- java.lang.Object
- - com.versionone.utils.Delegator.DelegateProxy

- All Implemented Interfaces:
    IDelegate, InvocationHandler
  Enclosing class:
    Delegator

      protected class Delegator.DelegateProxy
      extends Object
      implements IDelegate, InvocationHandler

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `DelegateProxy(Object target, Class targetClass, String methodName, Delegator template)` constructor supplying a Class passing in types not template

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Method` | `getMethod()` accessor for the method
    `Object` | `getTarget()` accessor for the target
    `Object` | `invoke()` convenience call to handle case of no arguments
    `Object` | `invoke(Object arg)` convenience call to handle case of one argument
    `Object` | `invoke(Object[] args)` basic call to method
    `Object` | `invoke(Object proxy, Method method, Object[] args)` method required by InvocationHandler so we can build dynamic Proxys
    `Object` | `invoke(Object arg1, Object arg2)` convenience call to handle case of two argument
    `protected void` | `validateArgs(Object[] args)` if uncommented in invoke this code will throw an IllegalArgument call if arguments are of the wrong type

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DelegateProxy

          protected DelegateProxy(Object target,
                                  Class targetClass,
                                  String methodName,
                                  Delegator template)

      constructor supplying a Class passing in types not template
      Parameters:
        `target` - possibly null target if null the method must be static
        `targetClass` - non-null class implementing a suitable method
        `methodName` - nun-null name of a public static method in target
        `template` - non-null template with the required arguemts and return

  - ### Method Detail

    - #### invoke

          public Object invoke()
                        throws IllegalArgumentException,
                               Delegator.DelegateInvokeException

      convenience call to handle case of no arguments
      Specified by:
        `invoke` in interface `IDelegate`
      Returns:
        Object
      Throws:
        `IllegalArgumentException`
        `Delegator.DelegateInvokeException`

    - #### invoke

          public Object invoke(Object arg)
                        throws IllegalArgumentException,
                               Delegator.DelegateInvokeException

      convenience call to handle case of one argument
      Specified by:
        `invoke` in interface `IDelegate`
      Parameters:
        `arg` - some argument
      Returns:
        Object
      Throws:
        `IllegalArgumentException`
        `Delegator.DelegateInvokeException`

    - #### invoke

          public Object invoke(Object arg1,
                               Object arg2)
                        throws IllegalArgumentException,
                               Delegator.DelegateInvokeException

      convenience call to handle case of two argument
      Specified by:
        `invoke` in interface `IDelegate`
      Parameters:
        `arg1` - some argument
        `arg2` - some argument
      Returns:
        Object
      Throws:
        `IllegalArgumentException`
        `Delegator.DelegateInvokeException`

    - #### invoke

          public Object invoke(Object proxy,
                               Method method,
                               Object[] args)

      method required by InvocationHandler so we can build dynamic Proxys
      Specified by:
        `invoke` in interface `InvocationHandler`
      Parameters:
        `proxy` - object for which we are a proxy (ignored)
        `method` - method to call (ignored)
        `args` - arguments to pass
      Returns:
        Object - primitive types are wrapped

    - #### invoke

          public Object invoke(Object[] args)
                        throws IllegalArgumentException,
                               Delegator.DelegateInvokeException

      basic call to method
      Specified by:
        `invoke` in interface `IDelegate`
      Parameters:
        `args` - method arguments
      Returns:
        Object
      Throws:
        `IllegalArgumentException`
        `Delegator.DelegateInvokeException`

    - #### validateArgs

          protected void validateArgs(Object[] args)
                               throws IllegalArgumentException

      if uncommented in invoke this code will throw an IllegalArgument call if arguments are of the wrong type
      Parameters:
        `args` - - Object
      Throws:
        `IllegalArgumentException` - - IllegalArgumentException

    - #### getMethod

          public Method getMethod()

      accessor for the method
      Returns:
        Method - Method

    - #### getTarget

          public Object getTarget()

      accessor for the target
      Returns:
        Object - Object

Copyright © 2022 VersionOne, Inc.. All rights reserved.