Package ru.ispras.fortress.data
Class Random.CompositeEngine
- java.lang.Object
-
- ru.ispras.fortress.data.Random.CompositeEngine
-
- All Implemented Interfaces:
Random.Engine
- Enclosing class:
- Random
public static final class Random.CompositeEngine extends java.lang.Object implements Random.Engine
TheRandom.CompositeEngine
class is a reusable implementation of the Engine interface. It uses a set of objects that provide facilities to set up the randomizer and to generate data of specific types.
-
-
Constructor Summary
Constructors Constructor Description CompositeEngine(Random.Initializer initializer)
Constructs a CompositeEngine object that uses the specified initializer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Data
random(DataTypeId typeId, int size)
Generated random data of the specified type and size.void
setGenerator(DataTypeId typeId, Random.TypedGenerator generator)
Sets a generator responsible for generating data of the specified type.void
setSeed(int seed)
Sets a new seed of the random data generation engine.void
setUp()
Sets up the generation engine (if it requires some setup before being used).
-
-
-
Constructor Detail
-
CompositeEngine
public CompositeEngine(Random.Initializer initializer)
Constructs a CompositeEngine object that uses the specified initializer.- Parameters:
initializer
- Initializer to be used to set up the randomizer.
-
-
Method Detail
-
setGenerator
public void setGenerator(DataTypeId typeId, Random.TypedGenerator generator)
Sets a generator responsible for generating data of the specified type.- Parameters:
typeId
- Type identifier.generator
- Generator to the specified type.- Throws:
java.lang.IllegalArgumentException
- if any of the parameters equalsnull
.
-
setUp
public void setUp()
Description copied from interface:Random.Engine
Sets up the generation engine (if it requires some setup before being used).- Specified by:
setUp
in interfaceRandom.Engine
-
setSeed
public void setSeed(int seed)
Description copied from interface:Random.Engine
Sets a new seed of the random data generation engine.- Specified by:
setSeed
in interfaceRandom.Engine
- Parameters:
seed
- The seed to be set.
-
random
public Data random(DataTypeId typeId, int size)
Generated random data of the specified type and size.- Specified by:
random
in interfaceRandom.Engine
- Parameters:
typeId
- Data type identifier.size
- Data type size (in bits).- Returns:
- A random data.
- Throws:
java.lang.IllegalArgumentException
- if the typeId parameter equalsnull
.java.lang.UnsupportedOperationException
- if random data generation is not supported by the given data type.
-
-