static class BaseDataType.WrapperHandler
extends java.lang.Object
implements java.lang.reflect.InvocationHandler
Modifier and Type | Field and Description |
---|---|
private BaseDataType |
fallbackValue
A fallback value of proxy's data type which is assigned from target
|
private boolean |
identity
The target has the same data type as the proxy
|
private java.lang.Class<? extends BaseDataType> |
proxyDataType
The data type of the proxy
|
private BaseDataType |
target
The underlying value which is proxied
|
Constructor and Description |
---|
WrapperHandler(BaseDataType target,
java.lang.Class<? extends BaseDataType> proxyDataType)
Basic constructor.
|
Modifier and Type | Method and Description |
---|---|
private void |
initFallback()
Helper method to build a fallback value.
|
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
The invoke method of the invocation handler.
|
private java.lang.Class<? extends BaseDataType> proxyDataType
private BaseDataType target
private BaseDataType fallbackValue
private boolean identity
WrapperHandler(BaseDataType target, java.lang.Class<? extends BaseDataType> proxyDataType)
target
- The underlying value which is proxiedproxyDataType
- The data type of the proxypublic java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
val
to identify
the underlying value and fallback
to trigger an assign of the underlying value
to proxy's data type. Any other method is delegated to the fallback value to keep availability.
The fallback plan should be avoided, usually, by a proxy check in the calling context.invoke
in interface java.lang.reflect.InvocationHandler
private void initFallback() throws java.lang.InstantiationException, java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.IllegalAccessException