Package org.itsallcode.whiterabbit.api
Class AbstractPlugin<S extends PluginFeature>
- java.lang.Object
-
- org.itsallcode.whiterabbit.api.AbstractPlugin<S>
-
- All Implemented Interfaces:
Plugin
public abstract class AbstractPlugin<S extends PluginFeature> extends java.lang.Object implements Plugin
-
-
Field Summary
Fields Modifier and Type Field Description protected PluginConfigurationconfig
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractPlugin(java.lang.String id, java.lang.Class<S> featureType)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()Called before closing the plugin.protected abstract ScreateInstance()<T extends PluginFeature>
java.util.Optional<T>getFeature(java.lang.Class<T> featureType)Get an instance of the given feature type.java.lang.StringgetId()The ID of this plugin.voidinit(PluginConfiguration config)Called once when loading the plugin.booleansupports(java.lang.Class<? extends PluginFeature> featureType)Check if this plugin supports the given feature.
-
-
-
Field Detail
-
config
protected PluginConfiguration config
-
-
Constructor Detail
-
AbstractPlugin
protected AbstractPlugin(java.lang.String id, java.lang.Class<S> featureType)
-
-
Method Detail
-
init
public void init(PluginConfiguration config)
Description copied from interface:PluginCalled once when loading the plugin.
-
getId
public java.lang.String 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
public boolean supports(java.lang.Class<? extends PluginFeature> featureType)
Description copied from interface:PluginCheck if this plugin supports the given feature.
-
createInstance
protected abstract S createInstance()
-
getFeature
public <T extends PluginFeature> java.util.Optional<T> getFeature(java.lang.Class<T> featureType)
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.
-
-