Class EnumRandomizer<E extends Enum<E>>
java.lang.Object
org.jeasy.random.randomizers.AbstractRandomizer<E>
org.jeasy.random.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
.- Author:
- Mahmoud Ben Hassine ([email protected])
-
Field Summary
Fields inherited from class org.jeasy.random.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, 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 org.jeasy.random.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
-
-
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
-