Package: org.apache.groovy.plugin

## [Java] Class GroovyRunnerRegistry

- org.apache.groovy.plugin.GroovyRunnerRegistry

- All Implemented Interfaces and Traits:
    Map, Iterable

      public class GroovyRunnerRegistry
      extends Object
      implements Map, Iterable

  Registry of services that implement the GroovyRunner interface.

  This registry makes use of the ServiceLoader facility. The preferred method for registering new GroovyRunner providers is to place them in a provider-configuration file in the resource directory `META-INF/services`. The preferred method for accessing the registered runners is by making use of the `Iterable` interface using an enhanced for-loop.

  For compatibility with previous versions, this registry implements the Map interface. All `null` keys and values will be ignored and no exception thrown, except where noted.

  By default the registry contains runners that are capable of running `JUnit 3` and `JUnit 4` test classes if those libraries are available to the class loader.

  Since:
    2.5.0

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public void` | `clear()` Clears all registered runners from the registry and resets the registry so that it contains only the default set of runners.
    `` | `public boolean` | `containsKey(Object key)` Returns `true` if a runner was registered with the specified key.
    `` | `public boolean` | `containsValue(Object runner)` Returns `true` if registry contains the given runner instance.
    `` | `public Set<Entry<String, GroovyRunner>>` | `entrySet()` Returns a set of entries for registered runners.
    `` | `public GroovyRunner` | `get(Object key)` Returns the registered runner for the specified key.
    `` | `public static GroovyRunnerRegistry` | `getInstance()` Returns a reference to the one and only registry instance.
    `` | `public boolean` | `isEmpty()` Returns `true` if the registry contains no runners, else `false`.
    `` | `public Iterator<GroovyRunner>` | `iterator()` Returns an iterator for all runners that are registered.
    `` | `public Set<String>` | `keySet()` Set of all keys associated with registered runners.
    `` | `public void` | `load(ClassLoader classLoader)` Loads GroovyRunner instances using the ServiceLoader facility.
    `` | `public GroovyRunner` | `put(String key, GroovyRunner runner)` Registers a runner with the specified key.
    `` | `public void` | `putAll(Map<? extends String, ? extends GroovyRunner> m)` Adds all entries from the given Map to the registry.
    `` | `public GroovyRunner` | `remove(Object key)` Removes a registered runner from the registry.
    `` | `public int` | `size()` Returns the number of registered runners.
    `` | `public String` | `toString()`
    `` | `public Collection<GroovyRunner>` | `values()` Returns a collection of all registered runners.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### public void clear()

      Clears all registered runners from the registry and resets the registry so that it contains only the default set of runners.

    - #### public boolean containsKey(Object key)

      Returns `true` if a runner was registered with the specified key.

      Parameters:
        `key` - for the registered runner
      Returns:
        `true` if a runner was registered with given key

    - #### public boolean containsValue(Object runner)

      Returns `true` if registry contains the given runner instance.

      Parameters:
        `runner` - instance of a GroovyRunner
      Returns:
        `true` if the given runner is registered

    - #### public Set<Entry<String, GroovyRunner>> entrySet()

      Returns a set of entries for registered runners. This is a snapshot of the registry and any subsequent registry changes will not be reflected in the set.

      Returns:
        an unmodifiable set of registered runner entries

    - #### public GroovyRunner get(Object key)

      Returns the registered runner for the specified key.

      Parameters:
        `key` - used to look up the runner
      Returns:
        the runner registered with the given key

    - #### public static GroovyRunnerRegistry getInstance()

      Returns a reference to the one and only registry instance.

      Returns:
        registry instance

    - #### public boolean isEmpty()

      Returns `true` if the registry contains no runners, else `false`.

      Returns:
        `true` if no runners are registered

    - #### public Iterator<GroovyRunner> iterator()

      Returns an iterator for all runners that are registered. The returned iterator is a snapshot of the registry at the time the iterator is created. This iterator does not support removal.

      Returns:
        iterator for all registered runners

    - #### public Set<String> keySet()

      Set of all keys associated with registered runners. This is a snapshot of the registry and any subsequent registry changes will not be reflected in the set.

      Returns:
        an unmodifiable set of keys for registered runners

    - #### public void load(ClassLoader classLoader)

      Loads GroovyRunner instances using the ServiceLoader facility.

      Parameters:
        `classLoader` - used to locate provider-configuration files and classes

    - #### public GroovyRunner put(String key, GroovyRunner runner)

      Registers a runner with the specified key.

      Parameters:
        `key` - to associate with the runner
        `runner` - the runner to register
      Returns:
        the previously registered runner for the given key, if no runner was previously registered for the key then `null`

    - #### public void putAll(Map<? extends String, ? extends GroovyRunner> m)

      Adds all entries from the given Map to the registry. Any entries in the provided Map that contain a `null` key or value will be ignored.

      throws:
        NullPointerException if the given Map is `null`
      Parameters:
        `m` - entries to add to the registry

    - #### public GroovyRunner remove(Object key)

      Removes a registered runner from the registry.

      Parameters:
        `key` - of the runner to remove
      Returns:
        the runner instance that was removed, if no runner instance was removed then `null`

    - #### public int size()

      Returns the number of registered runners.

      Returns:
        number of registered runners

    - #### public String toString()

    - #### public Collection<GroovyRunner> values()

      Returns a collection of all registered runners. This is a snapshot of the registry and any subsequent registry changes will not be reflected in the collection.

      Returns:
        an unmodifiable collection of registered runner instances