Class ExtensionModuleRegistry

java.lang.Object
org.codehaus.groovy.runtime.m12n.ExtensionModuleRegistry

public class ExtensionModuleRegistry extends Object
The extension method registry is responsible for collecting methods (or static methods) which are added to existing classes and may be called like regular methods.

In previous Groovy versions, such methods could only be defined in a single class called DefaultGroovyMethods for instance methods, and DefaultGroovyStaticMethods for static methods.

Since:
2.0.0
  • Constructor Details

    • ExtensionModuleRegistry

      public ExtensionModuleRegistry()
      Constructs a new ExtensionModuleRegistry with an empty module list.
  • Method Details

    • addModule

      public void addModule(ExtensionModule module)
      Adds an extension module to this registry.
      Parameters:
      module - the extension module to add
    • removeModule

      public void removeModule(ExtensionModule module)
      Removes an extension module from this registry.
      Parameters:
      module - the extension module to remove
    • getModules

      public List<ExtensionModule> getModules()
      Returns a copy of the list of all registered extension modules.
      Returns:
      a list containing all registered extension modules
    • hasModule

      public boolean hasModule(String moduleName)
      Checks if an extension module with the given name is registered.
      Parameters:
      moduleName - the name of the module to check
      Returns:
      true if a module with the given name is registered, false otherwise
    • getModule

      public ExtensionModule getModule(String moduleName)
      Retrieves a registered extension module by its name.
      Parameters:
      moduleName - the name of the module to retrieve
      Returns:
      the extension module with the given name, or null if not found