Package io.lettuce.core.internal
Class AbstractInvocationHandler
- java.lang.Object
-
- io.lettuce.core.internal.AbstractInvocationHandler
-
- All Implemented Interfaces:
InvocationHandler
public abstract class AbstractInvocationHandler extends Object implements InvocationHandler
Abstract base class for invocation handlers.- Since:
- 4.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractInvocationHandler.MethodTranslator
-
Constructor Summary
Constructors Constructor Description AbstractInvocationHandler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
By default delegates toObject.equals(java.lang.Object)
so instances are only equal if they are identical.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, exceptObject.equals(java.lang.Object)
,Object.hashCode()
andObject.toString()
.int
hashCode()
By default delegates toObject.hashCode()
.Object
invoke(Object proxy, Method method, Object[] args)
proxy.hashCode()
delegates tohashCode()
proxy.toString()
delegates totoString()
proxy.equals(argument)
returns true if:proxy
andargument
are of the same type andequals(java.lang.Object)
returns true for theInvocationHandler
ofargument
other method calls are dispatched tohandleInvocation(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
.String
toString()
By default delegates toObject.toString()
.
-
-
-
Method Detail
-
invoke
public final Object invoke(Object proxy, Method method, Object[] args) throws Throwable
proxy.hashCode()
delegates tohashCode()
proxy.toString()
delegates totoString()
proxy.equals(argument)
returns true if:proxy
andargument
are of the same type- and
equals(java.lang.Object)
returns true for theInvocationHandler
ofargument
- other method calls are dispatched to
handleInvocation(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
.
- Specified by:
invoke
in interfaceInvocationHandler
- Parameters:
proxy
- the proxy instance that the method was invoked onmethod
- theMethod
instance corresponding to the interface method invoked on the proxy instance. The declaring class of theMethod
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.args
- an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, ornull
if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such asjava.lang.Integer
orjava.lang.Boolean
.- Returns:
- the invocation result value
- Throws:
Throwable
- the exception to throw from the method invocation on the proxy instance.
-
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, exceptObject.equals(java.lang.Object)
,Object.hashCode()
andObject.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.- Parameters:
proxy
- the proxy instance that the method was invoked onmethod
- theMethod
instance corresponding to the interface method invoked on the proxy instance. The declaring class of theMethod
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.args
- an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, ornull
if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such asjava.lang.Integer
orjava.lang.Boolean
.- Returns:
- the invocation result value
- Throws:
Throwable
- the exception to throw from the method invocation on the proxy instance.
-
equals
public boolean equals(Object obj)
By default delegates toObject.equals(java.lang.Object)
so instances are only equal if they are identical.proxy.equals(argument)
returns true if:proxy
andargument
are of the same type- and this method returns true for the
InvocationHandler
ofargument
Subclasses can override this method to provide custom equality.
-
hashCode
public int hashCode()
By default delegates toObject.hashCode()
. The dynamic proxies'hashCode()
will delegate to this method. Subclasses can override this method to provide custom equality.
-
toString
public String toString()
By default delegates toObject.toString()
. The dynamic proxies'toString()
will delegate to this method. Subclasses can override this method to provide custom string representation for the proxies.
-
-