Value - The type of value to generate@FunctionalInterface public interface RandomGenerator<Value>
RandomGenerator aims to provide a random value of a given type. Any
value of this type can be generated.RandomGenerator is a FunctionalInterface. It is not
intended to be directly implemented by a class, but instead to request a
method for generating random values, usually by using lambda expressions.| Modifier and Type | Method and Description |
|---|---|
static <T> RandomGenerator<T> |
filter(RandomGenerator<T> generator,
java.util.function.Predicate<T> filter)
Reduce a
RandomGenerator range. |
static <T> RandomGenerator<T> |
forArray(BoundedRandomGenerator<Integer> indexSelector,
T... values)
Create a
RandomGenerator over an array based on a random
selector. |
static <T> RandomGenerator<T> |
forCollection(BoundedRandomGenerator<Integer> indexSelector,
Collection<T> values)
Create a
RandomGenerator over a Collection based on a
random selector. |
static <T extends Enum<T>> |
forEnum(BoundedRandomGenerator<Integer> indexSelector,
Class<T> enumClass)
Create a
RandomGenerator over Enum values based on a
random selector. |
Value |
getRandomValue()
Generate a random value.
|
Value getRandomValue()
static <T> RandomGenerator<T> forCollection(BoundedRandomGenerator<Integer> indexSelector, Collection<T> values)
RandomGenerator over a Collection based on a
random selector.indexSelector - the random selectorvalues - the values to returnRandomGenerator on the provided values@SafeVarargs static <T> RandomGenerator<T> forArray(BoundedRandomGenerator<Integer> indexSelector, T... values)
RandomGenerator over an array based on a random
selector.indexSelector - the random selectorvalues - the values to returnRandomGenerator on the provided valuesstatic <T extends Enum<T>> RandomGenerator<T> forEnum(BoundedRandomGenerator<Integer> indexSelector, Class<T> enumClass)
RandomGenerator over Enum values based on a
random selector.indexSelector - the random selectorenumClass - the Enum to coverRandomGenerator on the Enum valuesstatic <T> RandomGenerator<T> filter(RandomGenerator<T> generator, java.util.function.Predicate<T> filter)
RandomGenerator range. The returned
RandomGenerator uses the provided one to generate random values,
but regenerate them if they do not pass the filter. Consequently, the
initial RandomGenerator may be called several times o generate a
single value. The impact on performance depends on the part of the
distribution which is filtered out: if a significant part of the
distribution is rejected, it might be more interesting to create a
dedicated RandomGenerator.generator - the RandomGenerator to filterfilter - the filter to pass to be an acceptable valueRandomGenerator which provides only acceptable valuesCopyright © 2018. All rights reserved.