org.unitils.core
Class ModulesRepository

java.lang.Object
  extended by org.unitils.core.ModulesRepository

public class ModulesRepository
extends Object

A class for holding and retrieving modules.

Author:
Tim Ducheyne, Filip Neven

Constructor Summary
ModulesRepository(List<Module> modules)
          Creates a repository containing the given modules.
 
Method Summary
<T extends Module>
T
getModuleOfType(Class<T> type)
          Gets the modules that is of the given type or a sub-type.
 List<Module> getModules()
          Gets all modules.
<T> List<T>
getModulesOfType(Class<T> type)
          Gets all modules that are of the given type or a sub-type.
 TestListener getTestListener(Module module)
          Gets the listener corresponding to the given module.
 Map<Module,TestListener> getTestListeners()
          Gets all listeners.
 boolean isModuleEnabled(Class<? extends Module> moduleClass)
          Checks whether a module of a type exists.
 boolean isModuleEnabled(String fullyQualifiedClassName)
          Checks whether a module of a type with the given class name exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModulesRepository

public ModulesRepository(List<Module> modules)
Creates a repository containing the given modules.

Parameters:
modules - the modules, not null
Method Detail

getModules

public List<Module> getModules()
Gets all modules.

Returns:
the modules, not null

getTestListeners

public Map<Module,TestListener> getTestListeners()
Gets all listeners.

Returns:
the listeners per module, not null

getModuleOfType

public <T extends Module> T getModuleOfType(Class<T> type)
Gets the modules that is of the given type or a sub-type. A UnitilsException is thrown when there is not exactly 1 possible match.

Type Parameters:
T - The module type
Parameters:
type - the module type, not null
Returns:
the module, not null

getModulesOfType

public <T> List<T> getModulesOfType(Class<T> type)
Gets all modules that are of the given type or a sub-type.

Type Parameters:
T - The module type
Parameters:
type - the type, not null
Returns:
the modules, an empty list if none found

isModuleEnabled

public boolean isModuleEnabled(String fullyQualifiedClassName)
Checks whether a module of a type with the given class name exists. The class name can also be the super-type of an existing module.

Parameters:
fullyQualifiedClassName - The class name, not null
Returns:
True if the module exists and is enabled

isModuleEnabled

public boolean isModuleEnabled(Class<? extends Module> moduleClass)
Checks whether a module of a type exists. The class an also be the super-type of an existing module.

Parameters:
moduleClass - The class, not null
Returns:
True if the module exists and is enabled

getTestListener

public TestListener getTestListener(Module module)
Gets the listener corresponding to the given module.

Parameters:
module - the module, not null
Returns:
the listener, null if the module could not be found


Copyright © 2011. All Rights Reserved.