Class DefaultExtensionManager
java.lang.Object
com.mewna.catnip.extension.manager.DefaultExtensionManager
- All Implemented Interfaces:
ExtensionManager
- Since:
- 9/6/18
- Author:
- amy
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncatnip()
Get all loaded extensions.loadExtension
(Extension extension) Load the given extension instance.matchingExtensions
(Class<T> extensionClass) Get all loaded extensions that are instantiated from the given class.matchingExtensions
(String regex) Get all loaded extensions whose names match the specified regex.void
shutdown()
Shuts down the extension manager and unloads all extensions.unloadExtension
(Extension extension) Unload the given extension instance.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.mewna.catnip.extension.manager.ExtensionManager
extension
-
Constructor Details
-
DefaultExtensionManager
-
-
Method Details
-
loadExtension
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 interfaceExtensionManager
- Parameters:
extension
- The extension to load.
-
unloadExtension
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 interfaceExtensionManager
- Parameters:
extension
- The extension to unload.
-
matchingExtensions
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 interfaceExtensionManager
- 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 interfaceExtensionManager
- 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
Description copied from interface:ExtensionManager
Get all loaded extensions. This method will only return extensions loaded by the current instance.- Specified by:
extensions
in interfaceExtensionManager
- 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 interfaceExtensionManager
-
catnip
- Specified by:
catnip
in interfaceExtensionManager
-