Class Options


public class Options extends AbstractProvider<BaseProviders>
Since:
0.8.0
  • Constructor Details

  • Method Details

    • option

      @SafeVarargs public final <E> E option(E... options)
      Returns a random element from an varargs.
      Type Parameters:
      E - The type of the elements in the varargs.
      Parameters:
      options - The varargs to take a random element from.
      Returns:
      A randomly selected element from the varargs.
    • subset

      public final <E> Set<E> subset(int size, E... options)
      Returns a random unique subset of elements from an varargs.
      Type Parameters:
      E - The type of the elements in the varargs.
      Parameters:
      size - The size of subset to return.
      options - The varargs to take a random element from.
      Returns:
      A randomly selected unique subset from the varargs. If size is negative then IllegalArgumentException will be thrown. If size is zero then an empty subset will be returned. If size is larger than a unique set from options then all options will be returned.
    • option

      public String option(String... options)
      Returns a random String element from an varargs.
      Parameters:
      options - The varargs to take a random element from.
      Returns:
      A randomly selected element from the varargs.
    • subset

      public final Set<String> subset(int size, String... options)
      Returns a random unique subset of elements from an varargs.
      Parameters:
      size - The size of subset to return.
      options - The varargs to take a random element from.
      Returns:
      A randomly selected unique subset from the varargs. If size is negative then IllegalArgumentException will be thrown. If size is zero then an empty subset will be returned. If size is larger than a unique set from options then all options will be returned.
    • option

      public <E extends Enum<E>> E option(Class<E> enumeration)
      Returns a random element from Enum.
      Parameters:
      enumeration - The Enum to take a random element from.
      Returns:
      A randomly selected element from the enum.
    • nextElement

      public <E> E nextElement(E[] array)
      Returns a random element from an array.
      Type Parameters:
      E - The type of the elements in the array.
      Parameters:
      array - The array to take a random element from.
      Returns:
      A randomly selected element from the array.
    • nextElement

      public <E> E nextElement(List<E> list)
      Returns a random element from a list.
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      list - The list to take a random element from.
      Returns:
      A randomly selected element from the list.