Class CallbackPropertyHandler<T>
- java.lang.Object
-
- org.pepstock.charba.client.commons.CallbackPropertyHandler<T>
-
- Type Parameters:
T- type of callback
public final class CallbackPropertyHandler<T> extends Object
It is managing property where can set a callback.
It uses a cache in order to be able to use the callback even if defined at default or chart options level, both for chart or plugin options.- Author:
- Andrea "Stock" Stocchero
-
-
Constructor Summary
Constructors Constructor Description CallbackPropertyHandler(Key property)Creates the object storing the property key to manage.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TgetCallback(NativeObjectContainer container)Returns the callback stored in the native object ornullif not exists.TgetCallback(NativeObjectContainer container, T defaultValue)Returns the callback stored in the native object or the default value passed as argument, if not exists.KeygetHashCodeProperty()Returns the property key used to store the class name plus hash code, as key of callback instance in the cache.KeygetProperty()Returns the property key to managebooleanremoveChartScope(String scope)Called byCallbackPropertyManagerwhen a chart is destroy in order to remove the scope (and then the callback if needed) from cache.voidsetCallback(AbstractNode container, String scope, T callback, CallbackProxy.Proxy proxy)Stores the callback in the cache, storing the proxy function and the hash code property key (unique id of callback) in the native object.voidsetCallback(NativeObjectContainer container, String scope, T callback, CallbackProxy.Proxy proxy)Stores the callback in the cache, storing the proxy function and the hash code property key (unique id of callback) in the native object.
-
-
-
Constructor Detail
-
CallbackPropertyHandler
public CallbackPropertyHandler(Key property)
Creates the object storing the property key to manage.- Parameters:
property- the property key to manage
-
-
Method Detail
-
getProperty
public Key getProperty()
Returns the property key to manage- Returns:
- the property key to manage
-
getHashCodeProperty
public Key getHashCodeProperty()
Returns the property key used to store the class name plus hash code, as key of callback instance in the cache.- Returns:
- the property key used to store the class name plus hash code, as key of callback instance in the cache
-
setCallback
public void setCallback(NativeObjectContainer container, String scope, T callback, CallbackProxy.Proxy proxy)
Stores the callback in the cache, storing the proxy function and the hash code property key (unique id of callback) in the native object.- Parameters:
container- container instance of native object to use to store the propertiesscope- the scope of callback, could be the default, chart type options, chart options, plugin objects, data setscallback- the java callback instance to cacheproxy- the proxy java script function to store in the native object
-
setCallback
public void setCallback(AbstractNode container, String scope, T callback, CallbackProxy.Proxy proxy)
Stores the callback in the cache, storing the proxy function and the hash code property key (unique id of callback) in the native object.- Parameters:
container- container instance of native object to use to store the propertiesscope- the scope of callback, could be the default, chart type options, chart options, plugin objects, data setscallback- the java callback instance to cacheproxy- the proxy java script function to store in the native object
-
getCallback
public T getCallback(NativeObjectContainer container)
Returns the callback stored in the native object ornullif not exists.- Parameters:
container- container instance of native object to use to get the unique key to retrieve the callback from cache- Returns:
- the callback stored in the native object or
nullif not exists
-
getCallback
public T getCallback(NativeObjectContainer container, T defaultValue)
Returns the callback stored in the native object or the default value passed as argument, if not exists.- Parameters:
container- container instance of native object to use to get the unique key to retrieve the callback from cachedefaultValue- default value to return if the callback does not exist- Returns:
- the callback stored in the native object or the default value passed as argument, if not exists
-
removeChartScope
public boolean removeChartScope(String scope)
Called byCallbackPropertyManagerwhen a chart is destroy in order to remove the scope (and then the callback if needed) from cache.- Parameters:
scope- the scope of the callback, is chart id- Returns:
trueif this callback handler has got 1 or more scope related to charts.
-
-