net.sf.adatagenerator.api
Interface GeneratorMap<B>

Type Parameters:
B - the bean type for which fields will be generated
C - an extension of the bean type. The generated fields may depend on fields defined only by the extension, even though extension-only fields themselves will not be generated.
All Known Implementing Classes:
AbstractGeneratorMap, FebrlGeneratorMap

public interface GeneratorMap<B>

A registry of field generators for bean. A registry has a simple life cycle:

  1. The registry is constructed.
  2. The registry is initialized by calling the buildGeneratorMap(FieldDependencyManager) method.
  3. The registry is used by calling the getInstance(String), getMemberNames() or the getSequencedFields() methods.
  4. The registry is discarded and garbage collected.
Subclasses that implement this interface should enforce this contract by throwing CreationException or ProcessingException, as appropriate, if a method can not be completed successfully or if it is called at an inappropriate point in the life cycle.

Author:
chirag

Method Summary
 void buildGeneratorMap(FieldDependencyManager<B> fdm)
          Initializes an instance.
 FieldGenerator<B,?> getInstance(String name)
          Returns the specified generator from this map, or null if a generator has not been registered for the specified field name.
 Set<String> getMemberNames()
          Provides unchecked, read-only access to the (unordered) set of names of the fields maintained by this instance.
 List<String> getSequencedFields()
          Provides validated, read-only access to the field sequence maintained by this instance.
 boolean isMapBuilt()
          Checks whether a map has been successfully initialized
 

Method Detail

buildGeneratorMap

void buildGeneratorMap(FieldDependencyManager<B> fdm)
                       throws CreationException
Initializes an instance. Clients must call this method before using a generator map; that is, before invoking the getInstance(String), getMemberNames() or the getSequencedFields() methods.

This method should check to see if a map has already been initialized. If not, it should try to initialize it and if successful, ensure that the isMapBuilt() method will return true subsequently. If a map has already been built, this method should have no effect.

Parameters:
fdm - the DefaultFieldDependencyManager used by this GeneratorMap
Throws:
CreationException - Subclasses must throw a CreationException if the method is unable to build a valid generator map

isMapBuilt

boolean isMapBuilt()
Checks whether a map has been successfully initialized


getSequencedFields

List<String> getSequencedFields()
                                throws ProcessingException
Provides validated, read-only access to the field sequence maintained by this instance.

Subclasses that implement this method should throw a ProcessingException if this method is called before the generator map is built.

Throws:
ProcessingException - if this method is invoked before a map is initialized.
See Also:
buildGeneratorMap(FieldDependencyManager);, isMapBuilt()

getMemberNames

Set<String> getMemberNames()
                           throws CreationException
Provides unchecked, read-only access to the (unordered) set of names of the fields maintained by this instance. This method is meant to be used by a field dependency manager in the implementation of the buildGeneratorMap(FieldDependencyManager) method. Subclasses may throw a CreationException if this method is invoked after a map is initialized.

Clients should not use this method; instead they should access the generators in this map in a prescribed sequence using the getSequencedFields() method.

Throws:
CreationException - if this method is after a map is initialized.
See Also:
buildGeneratorMap(FieldDependencyManager);, isMapBuilt()

getInstance

FieldGenerator<B,?> getInstance(String name)
                                throws CreationException
Returns the specified generator from this map, or null if a generator has not been registered for the specified field name. Names are case sensitive. Names are trimmed before they are used internally.

Subclasses that implement this method should throw a ProcessingException if this method is called before the generator map is built.

Parameters:
name - a non-null, non-blank field name
Returns:
the field generator that is registered for this field, or null if no generator has bee registered.
Throws:
CreationException - if this method is invoked before a map is initialized.


Copyright © 2011-2012. All Rights Reserved.