Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.common.reflect
Class AbstractInvocationHandler

    java.lang.Object
      com.google.common.reflect.AbstractInvocationHandler

All Implemented Interfaces:
  InvocationHandler

    @Beta
    public abstract class AbstractInvocationHandler

extends Object
implements InvocationHandler

Abstract implementation of `InvocationHandler` that handles `Object.equals(java.lang.Object)`, `Object.hashCode()` and `Object.toString()`.

Since:
  12.0
Author:
  Ben Yu

Constructor Summary
`AbstractInvocationHandler()`

Method Summary
`protected abstract Object` | `handleInvocation(Object proxy, Method method, Object[] args)` `invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])` delegates to this method upon any method invocation on the proxy instance, except `Object.equals(java.lang.Object)`, `Object.hashCode()` and `Object.toString()`.
`Object` | `invoke(Object proxy, Method method, Object[] args)`
`String` | `toString()` The dynamic proxies' `Object.toString()` will delegate to this method.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### AbstractInvocationHandler

    public AbstractInvocationHandler()

Method Detail

### invoke

    public final Object invoke(Object proxy,
                               Method method,
                               @Nullable
                               Object[] args)
                        throws Throwable

  `Object.equals(java.lang.Object)`, `Object.hashCode()` are implemented according to referential equality (the default behavior of `Object`). `Object.toString()` delegates to `toString()` that can be overridden by subclasses.

  Specified by:
    `invoke` in interface `InvocationHandler`
  Throws:
    `Throwable`

### handleInvocation

    protected abstract Object handleInvocation(Object proxy,
                                               Method method,
                                               Object[] args)
                                        throws Throwable

  `invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])` delegates to this method upon any method invocation on the proxy instance, except `Object.equals(java.lang.Object)`, `Object.hashCode()` and `Object.toString()`. The result will be returned as the proxied method's return value.

  Unlike `invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])`, `args` will never be null. When the method has no parameter, an empty array is passed in.

  Throws:
    `Throwable`

### toString

    public String toString()

  The dynamic proxies' `Object.toString()` will delegate to this method. Subclasses can override this to provide custom string representation of the proxies.

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010-2012. All Rights Reserved.