jInfer

cz.cuni.mff.ksi.jinfer.base.utils
Class ModuleSelectionHelper

java.lang.Object
  extended by cz.cuni.mff.ksi.jinfer.base.utils.ModuleSelectionHelper

public final class ModuleSelectionHelper
extends Object

Logic for looking up service provider implementations based on their name.


Nested Class Summary
static class ModuleSelectionHelper.Fallback
          Defines what should happen if none of the implementations has the name we look for.
 
Method Summary
static
<T extends NamedModule>
T
lookupImpl(Class<T> clazz, String name)
          Looks up implementation of requested interface based on its name.
static
<T extends NamedModule>
T
lookupImpl(Class<T> clazz, String name, ModuleSelectionHelper.Fallback fallback)
          Looks up implementation of requested interface based on its name.
static
<T extends NamedModule>
List<T>
lookupImpls(Class<T> clazz)
          Returns a list of all the implementations of requested interface registered via ServiceProvider.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

lookupImpls

public static <T extends NamedModule> List<T> lookupImpls(Class<T> clazz)
Returns a list of all the implementations of requested interface registered via ServiceProvider.

Type Parameters:
T - Interface for which the implementations to be found. Must extend NamedModule.
Parameters:
clazz - Interface for which the implementations to be found. Must extend NamedModule.
Returns:
List alphabetically sorted by NamedModule.getDisplayName() of all implementations of modules registered as ServiceProvider implementing the requested interface.

lookupImpl

public static <T extends NamedModule> T lookupImpl(Class<T> clazz,
                                                   String name)
Looks up implementation of requested interface based on its name.

Type Parameters:
T - Interface to be found. Must extend NamedModule.
Parameters:
clazz - Interface to be found. Must extend NamedModule.
name - Module name. This parameter will be compared to the names (NamedModule.getName()) of all implementations of the requested interface.
Returns:
Implementation with the correct name. If there is no implementation of this interface at all, runtime exception. If there are implementations but none has the correct name, first implementation (in alphabetic order) is returned.

lookupImpl

public static <T extends NamedModule> T lookupImpl(Class<T> clazz,
                                                   String name,
                                                   ModuleSelectionHelper.Fallback fallback)
Looks up implementation of requested interface based on its name.

Type Parameters:
T - Interface to be found. Must extend NamedModule.
Parameters:
clazz - Interface to be found. Must extend NamedModule.
name - Module name. This parameter will be compared to the names (NamedModule.getName()) of all implementations of the requested interface.
fallback - Defines what to do if no implementation with correct name is found.
Returns:
Implementation with the correct name. If there is no implementation of this interface at all, runtime exception. If there are implementations but none has the correct name, the behaviour depends on the fallback parameter. See ModuleSelectionHelper.Fallback.

jInfer

Generated on Fri Dec 9 00:01:25 CET 2011