org.jcheck.generator
Class ElementGen<T>
java.lang.Object
org.jcheck.generator.ElementGen<T>
- All Implemented Interfaces:
- Gen<T>
public class ElementGen<T>
- extends java.lang.Object
- implements Gen<T>
Generate a random object from the list of objects in the
constructor. This generator should be subclassed.
The following example will create a generator that will
generate only 2, 4 and 6.
public class TwoFourSixGen extends ElementGen<Integer>
{
public TwoFourSixGen()
{
super(2,4,6);
}
}
Method Summary |
T |
arbitrary(java.util.Random random,
long size)
Returns an arbitrary object of type T. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ElementGen
public ElementGen(T... objects)
arbitrary
public T arbitrary(java.util.Random random,
long size)
- Description copied from interface:
Gen
Returns an arbitrary object of type T. The object should
not have a size greater than size (or smaller than
-size). What the size actually referrs to depends on the
implementation, but it could be the number of nodes in a tree,
pixels in an image etc.
The supplied random generator should be the only source of randomness
used in the generator.
- Specified by:
arbitrary
in interface Gen<T>
- Parameters:
random
- the random generator that should be used when randomness is needed.size
- the limiting factor
- Returns:
- a random object