public class RandomRange
extends java.lang.Object
Constructor and Description |
---|
RandomRange(int minValue,
int maxValue)
Creates a new instance with a
SecureRandom for the generation
of values between minValue and maxValue (both inclusive). |
RandomRange(java.util.Random random,
int minValue,
int maxValue)
Creates a new instance with the given
Random implementation for the generation
of values between minValue and maxValue (both inclusive). |
Modifier and Type | Method and Description |
---|---|
static RandomRange |
create(int minValue,
int maxValue)
Creates a new instance with a
SecureRandom for the generation
of values between minValue and maxValue (both inclusive). |
static RandomRange |
create(java.util.Random random,
int minValue,
int maxValue)
Creates a new instance with the given
Random implementation for the generation
of values between minValue and maxValue (both inclusive). |
int |
getMaxValue()
Returns the maximum value that can be generated by this object.
|
int |
getMinValue()
Returns the minimum value that can be generated by this object.
|
protected java.util.Random |
getRandom() |
protected int |
getUpperBound() |
int |
nextInt()
Returns a new random integer value in the specified underlying range.
|
java.lang.String |
toString() |
public RandomRange(int minValue, int maxValue)
SecureRandom
for the generation
of values between minValue and maxValue (both inclusive).minValue
- The minimum integer value that could be produced by this instance.maxValue
- The maximum integer value that could be produced by this instance.public RandomRange(java.util.Random random, int minValue, int maxValue)
Random
implementation for the generation
of values between minValue and maxValue (both inclusive).minValue
- The minimum integer value that could be produced by this instance.maxValue
- The maximum integer value that could be produced by this instance.public static RandomRange create(int minValue, int maxValue)
SecureRandom
for the generation
of values between minValue and maxValue (both inclusive).minValue
- The minimum integer value that could be produced by this instance.maxValue
- The maximum integer value that could be produced by this instance.public static RandomRange create(java.util.Random random, int minValue, int maxValue)
Random
implementation for the generation
of values between minValue and maxValue (both inclusive).minValue
- The minimum integer value that could be produced by this instance.maxValue
- The maximum integer value that could be produced by this instance.public int nextInt()
public int getMinValue()
public int getMaxValue()
public java.lang.String toString()
toString
in class java.lang.Object
protected java.util.Random getRandom()
protected int getUpperBound()