Class ExtensionPoint<T extends PluginFeature>

java.lang.Object
nz.org.riskscape.engine.plugin.ExtensionPoint<T>
All Implemented Interfaces:
Identified

public class ExtensionPoint<T extends PluginFeature> extends Object implements Identified

An ExtensionPoint is an official advertised place that allows a Plugin to advertise a PluginFeature SPI and a place where implementing features should be registered by the plugin system during startup.

ExtensionPoints are advertised by adding them to the list returned by Plugin.getExtensionPoints()

TODO we might want to introduce some kind of bootstrapping thing? But that might in itself be a Feature. Going to leave that out for now and see what we neeed.

  • Constructor Details

    • ExtensionPoint

      public ExtensionPoint(Class<T> featureClass)
  • Method Details

    • getId

      public String getId()
      Specified by:
      getId in interface Identified
      Returns:
      id
    • addFeature

      public void addFeature(T feature)

      Add a feature to the list

    • addFeatureIf

      public boolean addFeatureIf(PluginFeature feature)

      Add a feature of unknown type to the list

      Returns:
      true if it was added (and the right type)
    • getFeatures

      public List<T> getFeatures()
      Returns:
      an immutable list of collected features for this extension point
    • checkFeatureClass

      public <U extends PluginFeature> Optional<ExtensionPoint<U>> checkFeatureClass(Class<U> ofClass)
      Returns:
      this ExtensionPoint cast to the given feature class. Useful when working with a specific extension point and you need to get java's generic types to shut up and leave you alone.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getFeatureClass

      public Class<T> getFeatureClass()

      The 'service provider interface' class for this extension. Any features that belong to this extension point are instances of this class.

      Note that this doesn't actually have to be an interface, but it's standard nomenclature for this sort of thing.