Class EnumRandomizer<E extends java.lang.Enum<E>>

  • Type Parameters:
    E - the type of elements in the enumeration
    All Implemented Interfaces:
    Randomizer<E>

    public class EnumRandomizer<E extends java.lang.Enum<E>>
    extends AbstractRandomizer<E>
    A Randomizer that generates a random value from a given Enum.
    Author:
    Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
    • Constructor Detail

      • EnumRandomizer

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

        public EnumRandomizer​(java.lang.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​(java.lang.Class<E> enumeration,
                              E... excludedValues)
                       throws java.lang.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:
        java.lang.IllegalArgumentException - when excludedValues contains all enumeration values, ie all elements from the enumeration are excluded
    • Method Detail

      • 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