Class DefaultExtensionManager

java.lang.Object
com.mewna.catnip.extension.manager.DefaultExtensionManager
All Implemented Interfaces:
ExtensionManager

public class DefaultExtensionManager extends Object implements ExtensionManager
Since:
9/6/18
Author:
amy
  • Constructor Details

    • DefaultExtensionManager

      public DefaultExtensionManager(Catnip catnip)
  • Method Details

    • loadExtension

      public ExtensionManager loadExtension(@Nonnull Extension extension)
      Description copied from interface: ExtensionManager
      Load the given extension instance. Note than an extension may not be loaded more than once, and attempting to load an extension multiple times will no-op.
      Specified by:
      loadExtension in interface ExtensionManager
      Parameters:
      extension - The extension to load.
    • unloadExtension

      public ExtensionManager unloadExtension(@Nonnull Extension extension)
      Description copied from interface: ExtensionManager
      Unload the given extension instance. If the extension is not already loaded, this method will be a no-op.
      Specified by:
      unloadExtension in interface ExtensionManager
      Parameters:
      extension - The extension to unload.
    • matchingExtensions

      @Nonnull public Set<Extension> matchingExtensions(@Nonnull String regex)
      Description copied from interface: ExtensionManager
      Get all loaded extensions whose names match the specified regex. This method will only return extensions loaded by the current instance.
      Specified by:
      matchingExtensions in interface ExtensionManager
      Parameters:
      regex - The regex to match extension names against.
      Returns:
      A possibly-empty set of extensions that have names matching the supplied regex.
    • matchingExtensions

      @Nonnull public <T extends Extension> Set<? extends T> matchingExtensions(@Nonnull Class<T> extensionClass)
      Description copied from interface: ExtensionManager
      Get all loaded extensions that are instantiated from the given class. This method will only return extensions loaded by the current instance.
      Specified by:
      matchingExtensions in interface ExtensionManager
      Type Parameters:
      T - Type of the extension.
      Parameters:
      extensionClass - The extension class to find instances of.
      Returns:
      A possibly-empty set of extensions that are instances of the supplied class.
    • extensions

      @Nonnull public Set<Extension> extensions()
      Description copied from interface: ExtensionManager
      Get all loaded extensions. This method will only return extensions loaded by the current instance.
      Specified by:
      extensions in interface ExtensionManager
      Returns:
      A possibly-empty set of extensions.
    • shutdown

      public void shutdown()
      Description copied from interface: ExtensionManager
      Shuts down the extension manager and unloads all extensions.
      Specified by:
      shutdown in interface ExtensionManager
    • catnip

      public Catnip catnip()
      Specified by:
      catnip in interface ExtensionManager