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 classAbstractInvocationHandler.MethodTranslator -
Constructor Summary
Constructors Constructor Description AbstractInvocationHandler() -
Method Summary
Modifier and Type Method Description booleanequals(Object obj)By default delegates toObject.equals(java.lang.Object)so instances are only equal if they are identical.protected abstract ObjecthandleInvocation(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().inthashCode()By default delegates toObject.hashCode().Objectinvoke(Object proxy, Method method, Object[] args)proxy.hashCode()delegates tohashCode()proxy.toString()delegates totoString()proxy.equals(argument)returns true if:proxyandargumentare of the same type andequals(java.lang.Object)returns true for theInvocationHandlerofargumentother method calls are dispatched tohandleInvocation(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]).StringtoString()By default delegates toObject.toString().
-
Constructor Details
-
AbstractInvocationHandler
public AbstractInvocationHandler()
-
-
Method Details
-
invoke
proxy.hashCode()delegates tohashCode()proxy.toString()delegates totoString()proxy.equals(argument)returns true if:proxyandargumentare of the same type- and
equals(java.lang.Object)returns true for theInvocationHandlerofargument
- other method calls are dispatched to
handleInvocation(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]).
- Specified by:
invokein interfaceInvocationHandler- Parameters:
proxy- the proxy instance that the method was invoked onmethod- theMethodinstance corresponding to the interface method invoked on the proxy instance. The declaring class of theMethodobject 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, ornullif interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such asjava.lang.Integerorjava.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 Throwableinvoke(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[]),argswill 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- theMethodinstance corresponding to the interface method invoked on the proxy instance. The declaring class of theMethodobject 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, ornullif interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such asjava.lang.Integerorjava.lang.Boolean.- Returns:
- the invocation result value
- Throws:
Throwable- the exception to throw from the method invocation on the proxy instance.
-
equals
By default delegates toObject.equals(java.lang.Object)so instances are only equal if they are identical.proxy.equals(argument)returns true if:proxyandargumentare of the same type- and this method returns true for the
InvocationHandlerofargument
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
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.
-