InvocationHandler that handles Object#equals, Object#hashCode and Object#toString. For example:
class Unsupported extends AbstractInvocationHandler {
protected Object handleInvocation(Object proxy, Method method, Object[] args) {
throw new UnsupportedOperationException();
}
}
CharSequence unsupported = Reflection.newProxy(CharSequence.class, new Unsupported());
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object
the reference object with which to compare. obj)Overrides java. Object#equals so instances are only equal if they are
identical.
|
| protected abstract Object | handleInvocation(Object proxy, Method method, @Nullable Object[] args)
|
| public int | |
| public final Object | invoke(Object
the proxy instance that the method was invoked on proxy, Method the method, @Nullable Object[] Method instance corresponding to
the interface method invoked on the proxy instance. The declaring
class of the Method object will be the interface that
the method was declared in, which may be a superinterface of the
proxy interface that the proxy class inherits the method through.an array of objects containing the values of the
arguments passed in the method invocation on the proxy instance,
or args)null if interface method takes no arguments.
Arguments of primitive types are wrapped in instances of the
appropriate primitive wrapper class, such as
java.lang.Integer or java.lang.Boolean.Implements java. |
| private static boolean | |
| public String |
| NO_ARGS | back to summary |
|---|---|
| private static final Object[] NO_ARGS | |
| AbstractInvocationHandler | back to summary |
|---|---|
| public AbstractInvocationHandler() | |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. By default delegates to
Subclasses can override this method to provide custom equality.
| |
| handleInvocation | back to summary |
|---|---|
| protected abstract Object handleInvocation(Object proxy, Method method, @Nullable Object[] args) throws Throwable
Unlike
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. By default delegates to
| |
| invoke | back to summary |
|---|---|
| public final Object invoke(Object proxy, Method method, @Nullable Object[] args) throws Throwable Implements java. Doc from java. Processes a method invocation on a proxy instance and returns the result. This method will be invoked on an invocation handler when a method is invoked on a proxy instance that it is associated with.
| |
| isProxyOfSameInterfaces | back to summary |
|---|---|
| private static boolean isProxyOfSameInterfaces(Object arg, Class<?> proxyClass) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. By default delegates to
| |