Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.pietschy.command.configuration.impl
Class ConfiguratorRegistry

    java.lang.Object
      com.pietschy.command.configuration.impl.ConfiguratorRegistry

     class ConfiguratorRegistry

extends java.lang.Object

This class provides an intelligent map for finding the best `Configurator` for a particular `Command` subclass. If an exact match isn't found, the registry searches through all the entries to find the configurator registered for the nearest ancestor.

Field Summary
`(package private) static java.lang.String` | `_ID_`
`(package private) java.util.HashMap<java.lang.Class,Configurator>` | `ancestors`
`(package private) java.util.HashMap<java.lang.Class,Configurator>` | `configurators`

Constructor Summary
`ConfiguratorRegistry()` Creates a new instance.

Method Summary
`(package private) java.lang.Class` | `findNearestAncestor(java.lang.Class clazz)` Finds the nearest ancestor of the specified class that has a registered configurator.
`Configurator` | `get(Command command)` Gets the best configurator for the specified command class.
`(package private) int` | `getLineage(java.lang.Class a, java.lang.Class b)` Gets the lineage between the two specified classes.
`void` | `register(java.lang.Class clazz, Configurator configurator)` Registers the specified configurator for instances of the specified class.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### _ID_

    static final java.lang.String _ID_

See Also:
  Constant Field Values

### configurators

    java.util.HashMap<java.lang.Class,Configurator> configurators

### ancestors

    java.util.HashMap<java.lang.Class,Configurator> ancestors

Constructor Detail

### ConfiguratorRegistry

    public ConfiguratorRegistry()

  Creates a new instance.

Method Detail

### register

    public void register(java.lang.Class clazz,
                         Configurator configurator)

  Registers the specified configurator for instances of the specified class. Subclasses of will also use this configurator if they don't have a configurator explicitly registered.

  Parameters:
    `clazz` - the command class.
    `configurator` - the configurator for the specified class.
  Throws:
    `java.lang.IllegalArgumentException` - if clazz isn't of type Command.
    `java.lang.NullPointerException` - if the configurator is `null`.

### get

    public Configurator get(Command command)

  Gets the best configurator for the specified command class. This searches through all the registered configurators to find the most specific instance.

  Parameters:
    `command` - the command to configure.

### findNearestAncestor

    java.lang.Class findNearestAncestor(java.lang.Class clazz)

  Finds the nearest ancestor of the specified class that has a registered configurator.

  Parameters:
    `clazz` - the command class of interest.
  Returns:
    the nearest ancestor of the specified class that has a registered configurator.

### getLineage

    int getLineage(java.lang.Class a,
                   java.lang.Class b)

  Gets the lineage between the two specified classes.

  Parameters:
    `a` - the parent class
    `b` - the decendant class
  Returns:
    the number of classes in the heirarchy b -> a.
  Throws:
    `java.lang.IllegalArgumentException` - if b isn't an instance of a.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006 - 2007 Andrew Pietsch