Class CoreRandomizers

java.lang.Object
io.github.cjstehno.testthings.rando.CoreRandomizers

public final class CoreRandomizers extends Object
Defines the core randomizers.
  • Constructor Details

    • CoreRandomizers

      public CoreRandomizers()
  • Method Details

    • constant

      public static <V> Randomizer<V> constant(V value)
      Defines a randomizer which will always return the same value... so not really random at all.
      Type Parameters:
      V - the type of the generated value
      Parameters:
      value - the value to be returned
      Returns:
      the randomizer
    • oneOf

      @SafeVarargs public static <V> Randomizer<V> oneOf(V... options)
      A randomizer that returns a value from a collection of values.
      Type Parameters:
      V - the type of the generated value
      Parameters:
      options - the available options
      Returns:
      the randomizer
    • oneOf

      public static <V extends Enum<V>> Randomizer<V> oneOf(Class<V> enumType)
      A randomizer that returns a value from one of the defined enum values.
      Type Parameters:
      V - the type of generated value
      Parameters:
      enumType - the type of enum (provides the values)
      Returns:
      the randomizer
    • onceEachOf

      public static <V> Randomizer<V> onceEachOf(Collection<V> values)
      A randomizer which will randomly select a value from the collection, popping that value off so that each value will only be used once.
      Type Parameters:
      V - the type of the generated value
      Parameters:
      values - the collection of values
      Returns:
      the randomizer
    • listOf

      public static <V> Randomizer<List<V>> listOf(Randomizer<Integer> countRando, Randomizer<V> valueRando)
      A randomizer which will generate a list of random values. The size of the generated list is also random.
      Type Parameters:
      V - the type of the generated value
      Parameters:
      countRando - the randomizer used to determine the list size
      valueRando - the randomizer used to determine the list values
      Returns:
      the randomizer
    • setOf

      public static <V> Randomizer<Set<V>> setOf(Randomizer<Integer> countRando, Randomizer<V> valueRando)
      A randomizer which will generate a set of random values. The size of the generated set is also random.
      Type Parameters:
      V - the type of the generated value
      Parameters:
      countRando - the randomizer used to determine the set size
      valueRando - the randomizer used to determine the set values
      Returns:
      the randomizer
    • mapOf

      public static <K, V> Randomizer<Map<K,V>> mapOf(Randomizer<Integer> countRando, Randomizer<K> keyRando, Randomizer<V> valueRando)
      A randomizer which will generate a map of random values. The size of the generated map is also random.
      Type Parameters:
      K - the type of the key value
      V - the type of the generated value
      Parameters:
      countRando - the randomizer used to determine the map size
      keyRando - the randomizer used to determine the map keys
      valueRando - the randomizer used to determine the map values
      Returns:
      the randomizer
    • mapOf

      public static <K, V> Randomizer<Map<K,V>> mapOf(Map<K,Randomizer<V>> randomizers)
      Given a map containing Randomizers mapped to keys, the generated randomizer will generate random values for the mapped keys, based on the configured randomizers.
      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      randomizers - the map of keys to randomizers
      Returns:
      the randomizer
    • arrayOf

      public static <V> Randomizer<V[]> arrayOf(Randomizer<Integer> countRando, Randomizer<V> valueRando)
      A randomizer which will generate an array of random values. The size of the generated array is also random.
      Type Parameters:
      V - the type of the generated value
      Parameters:
      countRando - the randomizer used to determine the array size
      valueRando - the randomizer used to determine the array values
      Returns:
      the randomizer
    • streamOf

      public static <V> Randomizer<Stream<V>> streamOf(Randomizer<Integer> countRando, Randomizer<V> valueRando)
      A randomizer which will generate a stream of random values. The size of the generated stream is also random.
      Type Parameters:
      V - the type of the generated value
      Parameters:
      countRando - the randomizer used to determine the stream size
      valueRando - the randomizer used to determine the stream values
      Returns:
      the randomizer