Class Plugins
- java.lang.Object
-
- org.pepstock.charba.client.configuration.Plugins
-
public class Plugins extends Object
Definitions about plugins options.
This is used to configure plugins (mainly the global ones).
Every plugin could have own configuration structure.
The java script object key is the plugin id.- Author:
- Andrea "Stock" Stocchero
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Key>
getAllIds()
Returns the unmodifiable list of registered plugin ids.IsChart
getChart()
Returns the chart instanceprotected ExtendedOptions
getConfiguration()
Returns the configuration element.protected ConfigurationOptions
getOptions()
Returns the configuration options.<T extends AbstractPluginOptions>
TgetOptions(String pluginId, AbstractPluginOptionsFactory<T> factory)
Returns the plugin options, if exist.
It uses a factory instance to create a plugin options.<T extends AbstractPluginOptions>
TgetOptions(AbstractPluginOptionsFactory<T> factory)
Returns the plugin options, if exist.
It uses a factory instance to create a plugin options.
If factory argument is not consistent,null
is returned.boolean
hasEnabled(String pluginId)
Returns if a global plugin has been set or not.boolean
hasOptions(String pluginId)
Checks if there is any options for a specific plugin, by its id.boolean
isEnabled(String pluginId)
Returns if a plugin is enabled or not.boolean
isEnabled(DefaultPluginId pluginId)
Returns if a default plugin is enabled or not.void
removeOptions(String pluginId)
Removes the plugin options.void
setEmptyOptions(String pluginId)
Sets an empty configuration for the plugin.
The plugin will use the default configurationvoid
setEnabled(String pluginId, boolean enabled)
Sets if a plugin must be enabled or not.void
setEnabled(DefaultPluginId plugin, boolean enabled)
Sets if a default plugin must be enabled or not.<T extends AbstractPluginOptions>
voidsetOptions(String pluginId, T options)
Sets the plugin options.
If passed options is null, the configuration of plugin will be removed.<T extends AbstractPluginOptions>
voidsetOptions(T options)
Sets the plugin options.
-
-
-
Method Detail
-
getAllIds
public final List<Key> getAllIds()
Returns the unmodifiable list of registered plugin ids.- Returns:
- the unmodifiable list of registered plugin ids
-
setEnabled
public void setEnabled(String pluginId, boolean enabled)
Sets if a plugin must be enabled or not.- Parameters:
pluginId
- plugin id.enabled
-false
disable a plugin.
-
setEnabled
public void setEnabled(DefaultPluginId plugin, boolean enabled)
Sets if a default plugin must be enabled or not.- Parameters:
plugin
- default plugin instance.enabled
-false
disable a default plugin.
-
isEnabled
public boolean isEnabled(String pluginId)
Returns if a plugin is enabled or not.- Parameters:
pluginId
- plugin id.- Returns:
false
if a plugin is not enabled otherwisetrue
.
-
isEnabled
public boolean isEnabled(DefaultPluginId pluginId)
Returns if a default plugin is enabled or not.- Parameters:
pluginId
- default plugin id.- Returns:
false
if a default plugin is not enabled otherwisetrue
.
-
hasEnabled
public boolean hasEnabled(String pluginId)
Returns if a global plugin has been set or not.- Parameters:
pluginId
- plugin id.- Returns:
false
if a global plugin has not been set otherwisetrue
.
-
removeOptions
public void removeOptions(String pluginId)
Removes the plugin options.- Parameters:
pluginId
- plugin id.
-
setEmptyOptions
public void setEmptyOptions(String pluginId)
Sets an empty configuration for the plugin.
The plugin will use the default configuration- Parameters:
pluginId
- plugin id.
-
setOptions
public <T extends AbstractPluginOptions> void setOptions(T options)
Sets the plugin options.- Type Parameters:
T
- type of plugin options to store- Parameters:
options
- plugin options used to configure the plugin
-
setOptions
public <T extends AbstractPluginOptions> void setOptions(String pluginId, T options)
Sets the plugin options.
If passed options is null, the configuration of plugin will be removed.- Type Parameters:
T
- type of plugin options to store- Parameters:
pluginId
- plugin id.options
- plugin options used to configure the plugin.
Passnull
to remove the configuration if exist.
-
hasOptions
public boolean hasOptions(String pluginId)
Checks if there is any options for a specific plugin, by its id.- Parameters:
pluginId
- plugin id.- Returns:
true
if there is an options, otherwisefalse
.
-
getOptions
public <T extends AbstractPluginOptions> T getOptions(AbstractPluginOptionsFactory<T> factory)
Returns the plugin options, if exist.
It uses a factory instance to create a plugin options.
If factory argument is not consistent,null
is returned.- Type Parameters:
T
- type of plugin options to return- Parameters:
factory
- factory instance to create a plugin options- Returns:
- plugin options used to configure the plugin or an empty object if not exist.
If factory argument is not consistent,null
is returned.
-
getOptions
public <T extends AbstractPluginOptions> T getOptions(String pluginId, AbstractPluginOptionsFactory<T> factory)
Returns the plugin options, if exist.
It uses a factory instance to create a plugin options.- Type Parameters:
T
- type of plugin options to return- Parameters:
pluginId
- plugin id.factory
- factory instance to create a plugin options- Returns:
- plugin options used to configure the plugin or an empty object if not exist.
-
getOptions
protected final ConfigurationOptions getOptions()
Returns the configuration options.- Returns:
- the configuration options.
-
getConfiguration
protected final ExtendedOptions getConfiguration()
Returns the configuration element.- Returns:
- the configuration element.
-
getChart
public final IsChart getChart()
Returns the chart instance- Returns:
- the chart
-
-