public class DefaultPluginContext extends Object implements PluginContext
Constructor and Description |
---|
DefaultPluginContext() |
DefaultPluginContext(Map<String,Object> registry) |
Modifier and Type | Method and Description |
---|---|
<T> void |
addPlugin(String name,
T plugin)
Register a plugin in the context with the given name
|
<T> void |
addPlugin(T plugin)
Register a plugin in the context
|
Collection<PluginRef> |
getAllPlugins()
Return the complete list of all the plugins currently registered
|
<T> T |
getPlugin(Class<T> pluginClass)
Return an instance of the plugin matching the given type
given type
|
<T> T |
getPlugin(String pluginName)
Return an instance of the plugin that is registered with the given name
|
<T> boolean |
hasPlugin(Class<T> pluginClass)
Check if the context has a plugin with the given type
|
boolean |
hasPlugin(String pluginName)
Check if the context has a plugin with the given name
|
<T> T |
removePlugin(String pluginName)
Remove a plugin with the given name from the context
|
<T> T |
removePlugin(T plugin)
Remove a plugin from the context
|
@Nullable public <T> T getPlugin(String pluginName)
PluginContext
getPlugin
in interface PluginContext
T
- the inferred type of the pluginpluginName
- the name of the pluginnull
if none exists@Nullable public <T> T getPlugin(Class<T> pluginClass)
PluginContext
getPlugin
in interface PluginContext
T
- the inferred type of the pluginpluginClass
- type the plugin must match; can be an interface or superclass. Cannot be null
null
if none existspublic Collection<PluginRef> getAllPlugins()
PluginContext
getAllPlugins
in interface PluginContext
Collection
of all the pluginspublic <T> void addPlugin(T plugin)
PluginContext
addPlugin
in interface PluginContext
T
- the inferred type of the pluginplugin
- the plugin object to registerpublic <T> void addPlugin(String name, T plugin)
PluginContext
addPlugin
in interface PluginContext
T
- the inferred type of the pluginname
- the name to associate with the pluginplugin
- the plugin object to register@Nullable public <T> T removePlugin(T plugin)
PluginContext
removePlugin
in interface PluginContext
T
- the inferred type of the pluginplugin
- the plugin instance to removenull
if none is exists@Nullable public <T> T removePlugin(String pluginName)
PluginContext
removePlugin
in interface PluginContext
T
- the inferred type of the pluginpluginName
- the name associated with the pluginnull
if none is existspublic boolean hasPlugin(String pluginName)
PluginContext
hasPlugin
in interface PluginContext
pluginName
- the name associated with the plugintrue
if a plugin is present, false
otherwisepublic <T> boolean hasPlugin(Class<T> pluginClass)
PluginContext
hasPlugin
in interface PluginContext
pluginClass
- type the plugin must match; can be an interface or superclass.true
if a plugin is present, false
otherwiseCopyright © 2017–2018 PlugFace. All rights reserved.