Class EnumRandomizer<E extends Enum<E>>
java.lang.Object
io.github.krandom.randomizers.AbstractRandomizer<E>
io.github.krandom.randomizers.misc.EnumRandomizer<E>
- Type Parameters:
E
- the type of elements in the enumeration
- All Implemented Interfaces:
Randomizer<E>
A
Randomizer
that generates a random value from a given Enum
.-
Field Summary
Fields inherited from class io.github.krandom.randomizers.AbstractRandomizer
random
-
Constructor Summary
ConstructorsConstructorDescriptionEnumRandomizer
(Class<E> enumeration) Create a newEnumRandomizer
.EnumRandomizer
(Class<E> enumeration, long seed) Create a newEnumRandomizer
.EnumRandomizer
(Class<E> enumeration, long seed, E... excludedValues) Create a newEnumRandomizer
.EnumRandomizer
(Class<E> enumeration, E... excludedValues) Create a newEnumRandomizer
. -
Method Summary
Modifier and TypeMethodDescriptionGet a random value within an enumeration or an enumeration subset (when values are excluded)Methods inherited from class io.github.krandom.randomizers.AbstractRandomizer
getPredefinedValuesOf, nextDouble, toString
-
Constructor Details
-
EnumRandomizer
Create a newEnumRandomizer
.- Parameters:
enumeration
- the enumeration from which this randomizer will generate random values
-
EnumRandomizer
Create a newEnumRandomizer
.- Parameters:
enumeration
- the enumeration from which this randomizer will generate random valuesseed
- the initial seed
-
EnumRandomizer
Create a newEnumRandomizer
.- Parameters:
enumeration
- the enumeration from which this randomizer will generate random valuesexcludedValues
- the values to exclude from random picking- Throws:
IllegalArgumentException
- when excludedValues contains all enumeration values, ie all elements from the enumeration are excluded
-
EnumRandomizer
public EnumRandomizer(Class<E> enumeration, long seed, E... excludedValues) throws IllegalArgumentException Create a newEnumRandomizer
.- Parameters:
enumeration
- the enumeration from which this randomizer will generate random valuesseed
- the initial seedexcludedValues
- the values to exclude from random picking- Throws:
IllegalArgumentException
- when excludedValues contains all enumeration values, ie all elements from the enumeration are excluded
-
-
Method Details
-
getRandomValue
Get a random value within an enumeration or an enumeration subset (when values are excluded)- Returns:
- a random value within the enumeration
-