Class CoreRandomizers
java.lang.Object
io.github.cjstehno.testthings.rando.CoreRandomizers
Defines the core randomizers.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V> Randomizer<V[]>
arrayOf
(Randomizer<Integer> countRando, Randomizer<V> valueRando) A randomizer which will generate an array of random values.static <V> Randomizer<V>
constant
(V value) Defines a randomizer which will always return the same value...static <V> Randomizer<List<V>>
listOf
(Randomizer<Integer> countRando, Randomizer<V> valueRando) A randomizer which will generate a list of random values.static <K,
V> Randomizer<Map<K, V>> mapOf
(Randomizer<Integer> countRando, Randomizer<K> keyRando, Randomizer<V> valueRando) A randomizer which will generate a map of random values.static <K,
V> Randomizer<Map<K, V>> mapOf
(Map<K, Randomizer<V>> randomizers) Given a map containing Randomizers mapped to keys, the generated randomizer will generate random values for the mapped keys, based on the configured randomizers.static <V> Randomizer<V>
onceEachOf
(Collection<V> values) A randomizer which will randomly select a value from the collection, popping that value off so that each value will only be used once.static <V extends Enum<V>>
Randomizer<V>A randomizer that returns a value from one of the defined enum values.static <V> Randomizer<V>
oneOf
(V... options) A randomizer that returns a value from a collection of values.static <V> Randomizer<Set<V>>
setOf
(Randomizer<Integer> countRando, Randomizer<V> valueRando) A randomizer which will generate a set of random values.static <V> Randomizer<Stream<V>>
streamOf
(Randomizer<Integer> countRando, Randomizer<V> valueRando) A randomizer which will generate a stream of random values.
-
Constructor Details
-
CoreRandomizers
public CoreRandomizers()
-
-
Method Details
-
constant
Defines a randomizer which will always return the same value... so not really random at all.- Type Parameters:
V
- the type of the generated value- Parameters:
value
- the value to be returned- Returns:
- the randomizer
-
oneOf
A randomizer that returns a value from a collection of values.- Type Parameters:
V
- the type of the generated value- Parameters:
options
- the available options- Returns:
- the randomizer
-
oneOf
A randomizer that returns a value from one of the defined enum values.- Type Parameters:
V
- the type of generated value- Parameters:
enumType
- the type of enum (provides the values)- Returns:
- the randomizer
-
onceEachOf
A randomizer which will randomly select a value from the collection, popping that value off so that each value will only be used once.- Type Parameters:
V
- the type of the generated value- Parameters:
values
- the collection of values- Returns:
- the randomizer
-
listOf
public static <V> Randomizer<List<V>> listOf(Randomizer<Integer> countRando, Randomizer<V> valueRando) A randomizer which will generate a list of random values. The size of the generated list is also random.- Type Parameters:
V
- the type of the generated value- Parameters:
countRando
- the randomizer used to determine the list sizevalueRando
- the randomizer used to determine the list values- Returns:
- the randomizer
-
setOf
public static <V> Randomizer<Set<V>> setOf(Randomizer<Integer> countRando, Randomizer<V> valueRando) A randomizer which will generate a set of random values. The size of the generated set is also random.- Type Parameters:
V
- the type of the generated value- Parameters:
countRando
- the randomizer used to determine the set sizevalueRando
- the randomizer used to determine the set values- Returns:
- the randomizer
-
mapOf
public static <K,V> Randomizer<Map<K,V>> mapOf(Randomizer<Integer> countRando, Randomizer<K> keyRando, Randomizer<V> valueRando) A randomizer which will generate a map of random values. The size of the generated map is also random.- Type Parameters:
K
- the type of the key valueV
- the type of the generated value- Parameters:
countRando
- the randomizer used to determine the map sizekeyRando
- the randomizer used to determine the map keysvalueRando
- the randomizer used to determine the map values- Returns:
- the randomizer
-
mapOf
Given a map containing Randomizers mapped to keys, the generated randomizer will generate random values for the mapped keys, based on the configured randomizers.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
randomizers
- the map of keys to randomizers- Returns:
- the randomizer
-
arrayOf
A randomizer which will generate an array of random values. The size of the generated array is also random.- Type Parameters:
V
- the type of the generated value- Parameters:
countRando
- the randomizer used to determine the array sizevalueRando
- the randomizer used to determine the array values- Returns:
- the randomizer
-
streamOf
public static <V> Randomizer<Stream<V>> streamOf(Randomizer<Integer> countRando, Randomizer<V> valueRando) A randomizer which will generate a stream of random values. The size of the generated stream is also random.- Type Parameters:
V
- the type of the generated value- Parameters:
countRando
- the randomizer used to determine the stream sizevalueRando
- the randomizer used to determine the stream values- Returns:
- the randomizer
-