Class StringRandomizers
java.lang.Object
io.github.cjstehno.testthings.rando.StringRandomizers
A collection of randomizers for generating strings.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Randomizer<Character>
aChar()
Randomly generates a character (letters only).static Randomizer<String>
alphabetic
(Randomizer<Integer> countRando) Generates a random alphabetic string (upper and lower case).static Randomizer<String>
alphanumeric
(Randomizer<Integer> countRando) Generates a random alphanumeric string (upper and lower case).static Randomizer<char[]>
charArray
(Randomizer<Integer> countRando) Randomly generates a character array of random length.static Randomizer<String>
letter()
Generates a random letter (upper or lower case).static Randomizer<String>
number()
Generates a random number string (one number).static Randomizer<String>
numeric
(Randomizer<Integer> countRando) Generates a random numeric string (with multiple digits).static Randomizer<String>
Selects a random value from the characters of the given string.static Randomizer<String>
Randomly selects a word from the provided sentence (words are delimited by spaces).static Randomizer<String>
Randomly selects a word from the provided words.static Randomizer<String[]>
words
(Randomizer<Integer> countRando, Randomizer<Integer> wordSizeRando) Generates multiple alphabetic strings of random size, returned as an array of words.
-
Field Details
-
LETTERS
Letters of the alphabet (upper case).- See Also:
-
NUMBERS
Numbers from 0 to 9.- See Also:
-
-
Constructor Details
-
StringRandomizers
public StringRandomizers()
-
-
Method Details
-
oneFrom
Selects a random value from the characters of the given string.- Parameters:
string
- the string of values- Returns:
- the randomizer
-
letter
Generates a random letter (upper or lower case).- Returns:
- the randomizer
-
number
Generates a random number string (one number).- Returns:
- the randomizer
-
alphabetic
Generates a random alphabetic string (upper and lower case).- Parameters:
countRando
- the randomizer used to determine the length of the string- Returns:
- the randomizer
-
numeric
Generates a random numeric string (with multiple digits).- Parameters:
countRando
- the randomizer used to determine the length of the string- Returns:
- the randomizer
-
alphanumeric
Generates a random alphanumeric string (upper and lower case).- Parameters:
countRando
- the randomizer used to determine the length of the string- Returns:
- the randomizer
-
words
public static Randomizer<String[]> words(Randomizer<Integer> countRando, Randomizer<Integer> wordSizeRando) Generates multiple alphabetic strings of random size, returned as an array of words.- Parameters:
countRando
- the randomizer used to determine the number of wordswordSizeRando
- the randomizer used to determine the size of each word- Returns:
- the randomizer
-
wordFrom
Randomly selects a word from the provided sentence (words are delimited by spaces).- Parameters:
sentence
- the sentence- Returns:
- the randomizer
-
wordFrom
Randomly selects a word from the provided words.- Parameters:
words
- the available words- Returns:
- the randomizer
-
aChar
Randomly generates a character (letters only).- Returns:
- the randomizer
-
charArray
Randomly generates a character array of random length.- Parameters:
countRando
- the randomizer used to determine the length of the array- Returns:
- the randomizer
-