Package org.instancio
Interface Random
-
- All Known Implementing Classes:
DefaultRandom
public interface Random
Provides methods for generating random values such as numbers, booleans, characters, and strings.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description String
alphaNumeric(int length)
Generates a random alphanumeric String comprised of[a-z, A-Z, 0-9]
.byte
byteRange(byte min, byte max)
char
character()
Returns a random alphabetic character,[a-z, A-Z]
.boolean
diceRoll(boolean precondition)
String
digits(int length)
Generates a random String comprised of digits[0-9]
.double
doubleRange(double min, double max)
float
floatRange(float min, float max)
int
getSeed()
Returns the seed value used by the random number generator.int
intRange(int min, int max)
long
longRange(long min, long max)
String
lowerCaseAlphabetic(int length)
Generates a lower case String comprised of[a-z]
.char
lowerCaseCharacter()
Returns a random lower alphabetic character,[a-z]
.String
mixedCaseAlphabetic(int length)
Generates a random mixed case String comprised of[a-z, A-Z]
.<T> T
oneOf(Collection<T> collection)
Returns a random element from given collection.<T> T
oneOf(T... array)
Returns a random element from given array.short
shortRange(short min, short max)
boolean
trueOrFalse()
String
upperCaseAlphabetic(int length)
Generates a random upper case String comprised of[A-Z]
.char
upperCaseCharacter()
Returns a random upper alphabetic character,[A-Z]
.
-
-
-
Method Detail
-
getSeed
int getSeed()
Returns the seed value used by the random number generator.- Returns:
- seed value
-
trueOrFalse
boolean trueOrFalse()
- Returns:
- a random
true
orfalse
value with a0.5
probability.
-
diceRoll
boolean diceRoll(boolean precondition)
- Parameters:
precondition
- required for returningtrue
value- Returns:
- a random
true
with1/6
probability.
-
byteRange
byte byteRange(byte min, byte max)
- Parameters:
min
- lower boundmax
- upper bound (exclusive)- Returns:
- a random byte between the min and max, exclusive
-
shortRange
short shortRange(short min, short max)
- Parameters:
min
- lower boundmax
- upper bound (exclusive)- Returns:
- a random short between the min and max, exclusive
-
intRange
int intRange(int min, int max)
- Parameters:
min
- lower boundmax
- upper bound (exclusive)- Returns:
- a random int between the min and max, exclusive
-
longRange
long longRange(long min, long max)
- Parameters:
min
- lower boundmax
- upper bound (exclusive)- Returns:
- a random long between the min and max, exclusive
-
floatRange
float floatRange(float min, float max)
- Parameters:
min
- lower boundmax
- upper bound (exclusive)- Returns:
- a random float between the min and max, exclusive
-
doubleRange
double doubleRange(double min, double max)
- Parameters:
min
- lower boundmax
- upper bound (exclusive)- Returns:
- a random double between the min and max, exclusive
-
character
char character()
Returns a random alphabetic character,[a-z, A-Z]
.- Returns:
- random character, either lower or upper case
-
lowerCaseCharacter
char lowerCaseCharacter()
Returns a random lower alphabetic character,[a-z]
.- Returns:
- random lower character
-
upperCaseCharacter
char upperCaseCharacter()
Returns a random upper alphabetic character,[A-Z]
.- Returns:
- random uppercase character
-
lowerCaseAlphabetic
String lowerCaseAlphabetic(int length)
Generates a lower case String comprised of[a-z]
.- Parameters:
length
- of a string to generate- Returns:
- random lower case String with given length
-
upperCaseAlphabetic
String upperCaseAlphabetic(int length)
Generates a random upper case String comprised of[A-Z]
.- Parameters:
length
- of a string to generate- Returns:
- random upper case String with given length
-
mixedCaseAlphabetic
String mixedCaseAlphabetic(int length)
Generates a random mixed case String comprised of[a-z, A-Z]
.- Parameters:
length
- of a string to generate- Returns:
- random mixed case String with given length
-
alphaNumeric
String alphaNumeric(int length)
Generates a random alphanumeric String comprised of[a-z, A-Z, 0-9]
.- Parameters:
length
- of a string to generate- Returns:
- random alphanumeric String with given length
-
digits
String digits(int length)
Generates a random String comprised of digits[0-9]
.- Parameters:
length
- of a string to generate- Returns:
- random String comprised of digits with given length
-
oneOf
<T> T oneOf(T... array)
Returns a random element from given array.- Type Parameters:
T
- element type- Parameters:
array
- to pick a value from- Returns:
- random element
-
oneOf
<T> T oneOf(Collection<T> collection)
Returns a random element from given collection.- Type Parameters:
T
- element type- Parameters:
collection
- to pick a value from- Returns:
- random element
-
-