Package org.itsallcode.whiterabbit.api
Class AbstractPlugin<S extends PluginFeature>
java.lang.Object
org.itsallcode.whiterabbit.api.AbstractPlugin<S>
- Type Parameters:
S- the supportedPluginFeature.
- All Implemented Interfaces:
Plugin
Base class for plugins that support a defined
PluginFeature.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractPlugin(String id, Class<S> featureType) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Called before closing the plugin.protected abstract SPlugins must implement this and return a new instance of thePluginFeaturetype.final <T extends PluginFeature>
Optional<T> getFeature(Class<T> featureType) Get an instance of the given feature type.final StringgetId()The ID of this plugin.voidinit(PluginConfiguration config) Called once when loading the plugin.final booleansupports(Class<? extends PluginFeature> featureType) Check if this plugin supports the given feature.
-
Field Details
-
config
The plugin configuration. Will benulluntilinit(PluginConfiguration)was called.
-
-
Constructor Details
-
AbstractPlugin
Constructor.- Parameters:
id- the id of the new plugin.featureType- thePluginFeaturethat the new plugin supports.
-
-
Method Details
-
init
Description copied from interface:PluginCalled once when loading the plugin. -
getId
Description copied from interface:PluginThe ID of this plugin. IDs must be unique for all plugins. The ID is used as prefix forPluginConfiguration.getMandatoryValue(String). -
close
public void close()Description copied from interface:PluginCalled before closing the plugin. The plugin should cleanup any resources in this method. -
supports
Description copied from interface:PluginCheck if this plugin supports the given feature. -
createInstance
Plugins must implement this and return a new instance of thePluginFeaturetype.- Returns:
- a new
PluginFeatureinstance.
-
getFeature
Description copied from interface:PluginGet an instance of the given feature type.- Specified by:
getFeaturein interfacePlugin- Type Parameters:
T- the type of the feature.- Parameters:
featureType- the feature type.- Returns:
- the instance of the given feature or an empty
Optionalif the feature is not supported.
-