## org.codehaus.groovy.runtime
Class ConversionHandler

This class is a general adapter to map a call to an Java interface to a given delegate.

author:
  Ben Yu

author:
  Jochen Theodorou

Field Summary
`Object` | `delegate`

Constructor Summary
`ConversionHandler(Object delegate)` Creates a ConversionHandler with an deleagte.

Method Summary
`boolean` | `equals(Object obj)` This method is called for all Methods not defined on Object.
`Object` | `getDelegate()` gets the delegate.
`int` | `hashCode()` Returns a hash code value for the delegate.
`Object` | `invoke(Object proxy, Method method, def args)` This method is a default implementation for the invoke method given in Invocationhandler.
`Object` | `invokeCustom(Object proxy, Method method, def args)` This method is called for all Methods not defined on Object.
`static boolean` | `isObjectMethod(Method mtd)`
`String` | `toString()` Returns a String version of the delegate.

Constructor Detail

### ConversionHandler

    public ConversionHandler(Object delegate)

  Creates a ConversionHandler with an deleagte.
  param:
    delegate the delegate
  throws:
    IllegalArgumentException if the given delegate is null

Method Detail

### equals

    public boolean equals(Object obj)

  This method is called for all Methods not defined on Object. The delegate should be called here.
  param:
    proxy the proxy
  param:
    method the method
  param:
    args the arguments
  return:
    the result of the invocation of the delegate
  throws:
    Throwable any exception causes by the delegate
  see:
    #invoke(Object, Method, Object[])
  see:
    InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])

### getDelegate

    public Object getDelegate()

  gets the delegate.
  return:
    the delegate

### hashCode

    public int hashCode()

  Returns a hash code value for the delegate.
  see:
    Object#hashCode

### invoke

    public Object invoke(Object proxy, Method method, def args)

  This method is a default implementation for the invoke method given in Invocationhandler. Any call to an method with an declaring class that is not Object is redirected to invokeCustom. Methods like tostring, equals and hashcode are called on the class itself instead of the delegate. It is better to overwrite the invokeCustom method where the Object related methods are filtered out.
  see:
    #invokeCustom(Object, Method, Object[])
  see:
    InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
  param:
    proxy the proxy
  param:
    method the method
  param:
    args the arguments
  return:
    the result of the invocation by method or delegate
  throws:
    Throwable any exception caused by the delegate or the method

### invokeCustom

    public Object invokeCustom(Object proxy, Method method, def args)

  This method is called for all Methods not defined on Object. The delegate should be called here.
  param:
    proxy the proxy
  param:
    method the method
  param:
    args the arguments
  return:
    the result of the invocation of the delegate
  throws:
    Throwable any exception causes by the delegate
  see:
    #invoke(Object, Method, Object[])
  see:
    InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])

### isObjectMethod

    static boolean isObjectMethod(Method mtd)

### toString

    public String toString()

  Returns a String version of the delegate.
  see:
    Object#toString