net.java.quickcheck.generator.support
Class AbstractTreeGenerator<T>

java.lang.Object
  extended by net.java.quickcheck.generator.support.AbstractTreeGenerator<T>
Type Parameters:
T - type of tree node
All Implemented Interfaces:
Generator<T>

public abstract class AbstractTreeGenerator<T>
extends Object
implements Generator<T>

Base class for tree generators.

The callback order is:


Field Summary
static int MAX_TREE_DEPTH
           
 
Constructor Summary
AbstractTreeGenerator()
           
 
Method Summary
protected abstract  void addChildren(T node, List<T> children)
          Add the created children to the parent node.
protected abstract  T createNode()
          Create a node of type T.
protected abstract  int getChildCount(int level, int numberOfSiblings)
          Get the number of children for the current level.
 T next()
          Generates the next instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_TREE_DEPTH

public static final int MAX_TREE_DEPTH
See Also:
Constant Field Values
Constructor Detail

AbstractTreeGenerator

public AbstractTreeGenerator()
Method Detail

createNode

protected abstract T createNode()
Create a node of type T.


addChildren

protected abstract void addChildren(T node,
                                    List<T> children)
Add the created children to the parent node.


getChildCount

protected abstract int getChildCount(int level,
                                     int numberOfSiblings)
Get the number of children for the current level.

Parameters:
level - current level starting with 0 for the root level
numberOfSiblings - number of siblings (number of siblings is 1 for the root node.)

next

public T next()
Description copied from interface: Generator
Generates the next instance.

Specified by:
next in interface Generator<T>
Returns:
root node of the generated tree


Copyright © 2011. All Rights Reserved.