public class GroovyRunnerRegistry extends java.lang.Object implements java.util.Map<java.lang.String,GroovyRunner>, java.lang.Iterable<GroovyRunner>
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.
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears all registered runners from the registry and resets
the registry so that it contains only the default set of
runners.
|
boolean |
containsKey(java.lang.Object key)
Returns
true if a runner was registered with the
specified key. |
boolean |
containsValue(java.lang.Object runner)
Returns
true if registry contains the given
runner instance. |
java.util.Set<java.util.Map.Entry<java.lang.String,GroovyRunner>> |
entrySet()
Returns a set of entries for registered runners.
|
GroovyRunner |
get(java.lang.Object key)
Returns the registered runner for the specified key.
|
static GroovyRunnerRegistry |
getInstance()
Returns a reference to the one and only registry instance.
|
boolean |
isEmpty()
Returns
true if the registry contains no runners, else
false. |
java.util.Iterator<GroovyRunner> |
iterator()
Returns an iterator for all runners that are registered.
|
java.util.Set<java.lang.String> |
keySet()
Set of all keys associated with registered runners.
|
void |
load(java.lang.ClassLoader classLoader)
Loads
GroovyRunner instances using the ServiceLoader facility. |
GroovyRunner |
put(java.lang.String key,
GroovyRunner runner)
Registers a runner with the specified key.
|
void |
putAll(java.util.Map<? extends java.lang.String,? extends GroovyRunner> m)
Adds all entries from the given Map to the registry.
|
GroovyRunner |
remove(java.lang.Object key)
Removes a registered runner from the registry.
|
int |
size()
Returns the number of registered runners.
|
java.lang.String |
toString() |
java.util.Collection<GroovyRunner> |
values()
Returns a collection of all registered runners.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitpublic static GroovyRunnerRegistry getInstance()
public void load(java.lang.ClassLoader classLoader)
GroovyRunner instances using the ServiceLoader facility.classLoader - used to locate provider-configuration files and classespublic java.util.Iterator<GroovyRunner> iterator()
iterator in interface java.lang.Iterable<GroovyRunner>public int size()
size in interface java.util.Map<java.lang.String,GroovyRunner>public boolean isEmpty()
true if the registry contains no runners, else
false.isEmpty in interface java.util.Map<java.lang.String,GroovyRunner>true if no runners are registeredpublic boolean containsKey(java.lang.Object key)
true if a runner was registered with the
specified key.containsKey in interface java.util.Map<java.lang.String,GroovyRunner>key - for the registered runnertrue if a runner was registered with given keypublic boolean containsValue(java.lang.Object runner)
true if registry contains the given
runner instance.containsValue in interface java.util.Map<java.lang.String,GroovyRunner>runner - instance of a GroovyRunnertrue if the given runner is registeredpublic GroovyRunner get(java.lang.Object key)
get in interface java.util.Map<java.lang.String,GroovyRunner>key - used to lookup the runnerpublic GroovyRunner put(java.lang.String key, GroovyRunner runner)
put in interface java.util.Map<java.lang.String,GroovyRunner>key - to associate with the runnerrunner - the runner to registernullpublic GroovyRunner remove(java.lang.Object key)
remove in interface java.util.Map<java.lang.String,GroovyRunner>key - of the runner to removenullpublic void putAll(java.util.Map<? extends java.lang.String,? extends GroovyRunner> m)
null
key or value will be ignored.putAll in interface java.util.Map<java.lang.String,GroovyRunner>m - entries to add to the registryjava.lang.NullPointerException - if the given Map is nullpublic void clear()
clear in interface java.util.Map<java.lang.String,GroovyRunner>public java.util.Set<java.lang.String> keySet()
keySet in interface java.util.Map<java.lang.String,GroovyRunner>public java.util.Collection<GroovyRunner> values()
values in interface java.util.Map<java.lang.String,GroovyRunner>public java.util.Set<java.util.Map.Entry<java.lang.String,GroovyRunner>> entrySet()
entrySet in interface java.util.Map<java.lang.String,GroovyRunner>public java.lang.String toString()
toString in class java.lang.Object