Package de.cuioss.test.generator.impl
Class CollectionGenerator<T>
- java.lang.Object
-
- de.cuioss.test.generator.impl.CollectionGenerator<T>
-
- Type Parameters:
T- identifying the type of the object being generated
- All Implemented Interfaces:
TypedGenerator<T>
public class CollectionGenerator<T> extends Object implements TypedGenerator<T>
- Author:
- Oliver Wolff
-
-
Constructor Summary
Constructors Constructor Description CollectionGenerator(TypedGenerator<T> wrapped)Constructor.CollectionGenerator(TypedGenerator<T> wrapped, int lowerBound, int upperBound)Constructor.CollectionGenerator(TypedGenerator<T> wrapped, TypedGenerator<Integer> sizeGenerator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<T>list()List<T>list(int count)Returns aListof the elements provided by the generatorTnext()Generates the next instance.Iterable<T>nextCollection(Class<? extends Iterable<?>> expectedType)Generates a concreteIterable.Set<T>set()Set<T>set(int count)Returns aSetof the elements provided by the generatorSortedSet<T>sortedSet()SortedSet<T>sortedSet(int count)Returns aSortedSetof the elements provided by the generator-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.cuioss.test.generator.TypedGenerator
getType
-
-
-
-
Constructor Detail
-
CollectionGenerator
public CollectionGenerator(TypedGenerator<T> wrapped, TypedGenerator<Integer> sizeGenerator)
- Parameters:
wrapped- must not be nullsizeGenerator- must not be null
-
CollectionGenerator
public CollectionGenerator(TypedGenerator<T> wrapped, int lowerBound, int upperBound)
Constructor.- Parameters:
wrapped- generator, must not be nulllowerBound- defines the lower bound of the integer generator that determines the ofCollectionsizeupperBound- defines the upper bound of the integer generator that determines the ofCollectionsize
-
CollectionGenerator
public CollectionGenerator(TypedGenerator<T> wrapped)
Constructor. using 2 and 12 as bounds of theCollectionsize to be created.- Parameters:
wrapped- generator, must not be null
-
-
Method Detail
-
next
public T next()
Description copied from interface:TypedGeneratorGenerates the next instance.- Specified by:
nextin interfaceTypedGenerator<T>- Returns:
- the next object from the contained
TypedGenerator
-
list
public List<T> list(int count)
Returns aListof the elements provided by the generator- Parameters:
count- the number of elements within the list- Returns:
- a list with a given number of elements.
-
sortedSet
public SortedSet<T> sortedSet(int count)
Returns aSortedSetof the elements provided by the generator
-
sortedSet
public SortedSet<T> sortedSet()
- Returns:
- a
SortedSetwith a random number of elements as maximum.
-
nextCollection
public Iterable<T> nextCollection(Class<? extends Iterable<?>> expectedType)
Generates a concreteIterable. It is smart enough to determine whether the elements are to be wrapped in aList,Set,CollectionorSortedSet.
-
-