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>

public class EnumRandomizer<E extends Enum<E>> extends AbstractRandomizer<E>
A Randomizer that generates a random value from a given Enum.
Author:
Mahmoud Ben Hassine ([email protected])
  • Constructor Details

    • EnumRandomizer

      public EnumRandomizer(Class<E> enumeration)
      Create a new EnumRandomizer.
      Parameters:
      enumeration - the enumeration from which this randomizer will generate random values
    • EnumRandomizer

      public EnumRandomizer(Class<E> enumeration, long seed)
      Create a new EnumRandomizer.
      Parameters:
      enumeration - the enumeration from which this randomizer will generate random values
      seed - the initial seed
    • EnumRandomizer

      public EnumRandomizer(Class<E> enumeration, E... excludedValues) throws IllegalArgumentException
      Create a new EnumRandomizer.
      Parameters:
      enumeration - the enumeration from which this randomizer will generate random values
      excludedValues - 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

      public E getRandomValue()
      Get a random value within an enumeration or an enumeration subset (when values are excluded)
      Returns:
      a random value within the enumeration