Class RandomNumberOperation
- java.lang.Object
-
- de.gebit.integrity.runner.operations.RandomNumberOperation
-
- All Implemented Interfaces:
Operation<java.lang.Object,java.lang.Integer,java.math.BigDecimal>
public class RandomNumberOperation extends java.lang.Object implements Operation<java.lang.Object,java.lang.Integer,java.math.BigDecimal>
A random number generator. This one is special in several respects: it is automatically seeded on execution start, it caches randoms determined for every custom operation instance, and its seed is forwarded to forks to ensure their randomness is in sync with that of the master. All of this is required to safely work with random elements in Integrity tests. This operation doesn't have any input parameters, it just returns a random decimal number between 0 and 1.- Author:
- Rene Schneider - initial API and implementation
-
-
Constructor Summary
Constructors Constructor Description RandomNumberOperation()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.math.BigDecimal
execute(java.lang.Object aPrefixParameter, java.lang.Integer aPostfixParameter)
Executes the operation logic.static long
getSeed()
static void
seed(java.lang.Long aSeed)
Sets a new seed and reseeds the RNG.
-
-
-
Method Detail
-
seed
public static void seed(java.lang.Long aSeed)
Sets a new seed and reseeds the RNG.- Parameters:
aSeed
-
-
getSeed
public static long getSeed()
-
execute
public java.math.BigDecimal execute(java.lang.Object aPrefixParameter, java.lang.Integer aPostfixParameter)
Description copied from interface:Operation
Executes the operation logic.- Specified by:
execute
in interfaceOperation<java.lang.Object,java.lang.Integer,java.math.BigDecimal>
- Parameters:
aPrefixParameter
- the prefix parameter, or null if none was given or the value is not available at the time of the callaPostfixParameter
- the postfix parameter, or null if none was given or the value is not available at the time of the call- Returns:
- the result value
-
-