Package org.instancio.internal.random
Class RandomProvider
- java.lang.Object
-
- org.instancio.internal.random.RandomProvider
-
public class RandomProvider extends Object
-
-
Constructor Summary
Constructors Constructor Description RandomProvider()
Create an instance with a random seed value.RandomProvider(int seed)
Create an instance with the given seed value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
alphabetic(int length)
byte
byteBetween(byte min, byte max)
char
character()
boolean
diceRoll(boolean precondition)
double
doubleBetween(double min, double max)
float
floatBetween(float min, float max)
<T> T
from(Collection<T> collection)
<T> T
from(T[] array)
int
getSeed()
int
intBetween(int min, int max)
long
longBetween(long min, long max)
short
shortBetween(short min, short max)
boolean
trueOrFalse()
-
-
-
Method Detail
-
getSeed
public int getSeed()
-
trueOrFalse
public boolean trueOrFalse()
- Returns:
- a random
true
orfalse
value with a0.5
probability.
-
diceRoll
public boolean diceRoll(boolean precondition)
- Parameters:
precondition
- required for returningtrue
value- Returns:
- a random
true
with1/6
probability.
-
byteBetween
public byte byteBetween(byte min, byte max)
- Parameters:
min
- lower boundmax
- upper bound (exclusive)- Returns:
- a random byte between the min and max, exclusive
-
shortBetween
public short shortBetween(short min, short max)
- Parameters:
min
- lower boundmax
- upper bound (exclusive)- Returns:
- a random short between the min and max, exclusive
-
intBetween
public int intBetween(int min, int max)
- Parameters:
min
- lower boundmax
- upper bound (exclusive)- Returns:
- a random int between the min and max, exclusive
-
longBetween
public long longBetween(long min, long max)
- Parameters:
min
- lower boundmax
- upper bound (exclusive)- Returns:
- a random long between the min and max, exclusive
-
floatBetween
public float floatBetween(float min, float max)
- Parameters:
min
- lower boundmax
- upper bound (exclusive)- Returns:
- a random float between the min and max, exclusive
-
doubleBetween
public double doubleBetween(double min, double max)
- Parameters:
min
- lower boundmax
- upper bound (exclusive)- Returns:
- a random double between the min and max, exclusive
-
character
public char character()
- Returns:
- random uppercase character between A-Z inclusive.
-
alphabetic
public String alphabetic(int length)
- Parameters:
length
- of the string to generate- Returns:
- random uppercase String with given length
-
from
public <T> T from(T[] array)
-
from
public <T> T from(Collection<T> collection)
-
-