Class 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 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 properties
        scope - the scope of callback, could be the default, chart type options, chart options, plugin objects, data sets
        callback - the java callback instance to cache
        proxy - 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 properties
        scope - the scope of callback, could be the default, chart type options, chart options, plugin objects, data sets
        callback - the java callback instance to cache
        proxy - 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 or null if 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 null if 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 cache
        defaultValue - 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 by CallbackPropertyManager when 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:
        true if this callback handler has got 1 or more scope related to charts.