@Singleton public class BaseProducer extends Object
Constructor and Description |
---|
BaseProducer(RandomGenerator random) |
Modifier and Type | Method and Description |
---|---|
String |
bothify(String string)
Processes text with
numerify() and letterify() methods |
String |
letterify(String letterString)
Replaces all
'?' characters with random chars from [a - z] range |
String |
letterify(String letterString,
char from,
char to)
Replaces all
'?' characters with random chars from [from - to ] range |
String |
numerify(String numberString)
Replaces all
'#' characters with random numbers from [0 - 9] range |
String |
numerify(String numberString,
int from,
int to)
Replaces all
'#' characters with random numbers from [from - to ] range |
char |
randomBetween(char min,
char max) |
double |
randomBetween(double min,
double max)
Returns random double value
|
int |
randomBetween(int min,
int max)
Returns random int value
|
long |
randomBetween(long min,
long max)
Returns random long value from a range (including both range boundaries).
|
<T extends Enum<?>> |
randomElement(Class<T> enumType)
Returns random enum value
|
<T> T |
randomElement(List<T> elements)
Returns random element from passed List
|
String |
randomElement(String... elements)
Returns random element from passed vararg
|
<T> List<T> |
randomElements(List<T> elements,
int count)
Creates new list being random subset of the passed list
|
int |
randomInt(int max)
Returns random int value
|
boolean |
trueOrFalse()
Generates random boolean
|
@Inject public BaseProducer(RandomGenerator random)
public boolean trueOrFalse()
public <T> T randomElement(List<T> elements)
T
- element generic typeelements
- list to processpublic String randomElement(String... elements)
elements
- objects to processpublic <T extends Enum<?>> T randomElement(Class<T> enumType)
T
- element generic typeenumType
- enum classpublic <T> List<T> randomElements(List<T> elements, int count)
T
- element generic typeelements
- list to processcount
- returned list sizepublic int randomBetween(int min, int max)
min
- value of the random number to be returned. Must be positive.max
- value of the random number to be returned. Must be positive.int
value between min
(inclusive) and max
(inclusive)public int randomInt(int max)
max
- value of the random number to be returned. Must be positive.int
value between 0 (inclusive) and max
(inclusive)public char randomBetween(char min, char max)
public long randomBetween(long min, long max)
min
- lower bound of a rangemax
- higher bound of a rangelong
value between mon
(inclusive) and max
(inclusive)public double randomBetween(double min, double max)
min
- value of the random number to be returned. Must be positive.max
- value of the random number to be returned. Must be positive.double
value between min
(inclusive) and max
(inclusive)public String letterify(String letterString)
'?'
characters with random chars from [a - z] rangeletterString
- text to process'?'
charspublic String letterify(String letterString, char from, char to)
'?'
characters with random chars from [from
- to
] rangeletterString
- text to processfrom
- start of the rangeto
- end of the range'?'
charspublic String numerify(String numberString)
'#'
characters with random numbers from [0 - 9] rangenumberString
- text to processpublic String numerify(String numberString, int from, int to)
'#'
characters with random numbers from [from
- to
] rangenumberString
- text to processfrom
- start of the rangeto
- end of the rangeCopyright © 2020. All rights reserved.