org.deckfour.xes.util
Class XRegistry<T>

java.lang.Object
  extended by org.deckfour.xes.util.XRegistry<T>
Direct Known Subclasses:
XFactoryRegistry, XParserRegistry, XSerializerRegistry

public abstract class XRegistry<T>
extends Object

Template implementation for a generic registry.

Author:
Christian W. Guenther (christian@deckfour.org)

Constructor Summary
XRegistry()
          Instantiates a new registry.
 
Method Summary
protected abstract  boolean areEqual(T a, T b)
          Subclasses must implement this method.
 T currentDefault()
          Retrieves the current default instance.
 Set<T> getAvailable()
          Retrieves a set of all available instances.
protected  boolean isContained(T instance)
          Checks whether the given instance is already contained in the registry.
 void register(T instance)
          Registers a new instance with this registry.
 void setCurrentDefault(T instance)
          Sets the current default instance of this registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XRegistry

public XRegistry()
Instantiates a new registry.

Method Detail

getAvailable

public Set<T> getAvailable()
Retrieves a set of all available instances.


currentDefault

public T currentDefault()
Retrieves the current default instance.


register

public void register(T instance)
Registers a new instance with this registry.

Parameters:
instance - Instance to be registered.

setCurrentDefault

public void setCurrentDefault(T instance)
Sets the current default instance of this registry.

Parameters:
instance - Instance to be the current default of this registry.

areEqual

protected abstract boolean areEqual(T a,
                                    T b)
Subclasses must implement this method. It is used by the registry to ensure that no duplicates are inserted.

Parameters:
a - An instance a.
b - Another instance b.
Returns:
Whether the instances a and b are equivalent.

isContained

protected boolean isContained(T instance)
Checks whether the given instance is already contained in the registry.

Parameters:
instance - Instance to check against registry.
Returns:
Whether the given instance is already registered.