Package org.stubit.random
Class RandomChoice
java.lang.Object
org.stubit.random.RandomChoice
Randomly select an element from a collection of choices.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRandomly selects an element from a collection of choices. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> RandomChoice.Builder<T>aChoiceFrom(Collection<T> choices) static <K,V> RandomChoice.Builder<Map.Entry<K, V>> aChoiceFrom(Map<K, V> choices) static <T> RandomChoice.Builder<T>aChoiceFrom(T... choices) static <T extends Enum<?>>
RandomChoice.Builder<T>aChoiceFromValuesOf(Class<? extends T> enumType) static <T extends Enum<?>>
TRandomly selects an element from the values of the provided choicesEnumclass.static <T> TanyOf(Collection<T> choices) Randomly selects an element from the provided choicesCollection.static <K,V> Map.Entry<K, V> Randomly selects an element from the provided choicesCollection.static <T> TanyOf(T... choices) Randomly selects an element from the provided choices.
-
Method Details
-
anyOf
Randomly selects an element from the provided choicesCollection.- Type Parameters:
T- the type of the choices- Parameters:
choices- aCollectionof choices- Returns:
- a randomly selected element from the provided choices
-
anyOf
Randomly selects an element from the provided choicesCollection.- Type Parameters:
K- the type of the choices' keysV- the type of the choices' values- Parameters:
choices- aCollectionof choices- Returns:
- a randomly selected element from the provided choices
-
anyOf
Randomly selects an element from the provided choices.- Type Parameters:
T- the type of the choices- Parameters:
choices- an array of choices- Returns:
- a randomly selected element from the provided choices
-
any
Randomly selects an element from the values of the provided choicesEnumclass. -
aChoiceFrom
- Type Parameters:
T- the type of the choices- Parameters:
choices- aCollectionof choices- Returns:
- a new
RandomChoice.Builderwith the provided choices
-
aChoiceFrom
- Type Parameters:
K- the type of the choices' keysV- the type of the choices' values- Parameters:
choices- aCollectionof choices- Returns:
- a new
RandomChoice.Builderwith the provided choices
-
aChoiceFrom
- Type Parameters:
T- the type of the choices- Parameters:
choices- an array of choices- Returns:
- a new
RandomChoice.Builderwith the provided choices
-
aChoiceFromValuesOf
public static <T extends Enum<?>> RandomChoice.Builder<T> aChoiceFromValuesOf(Class<? extends T> enumType) - Type Parameters:
T- the type of the choices- Parameters:
enumType- theEnumtype- Returns:
- a new
RandomChoice.Builderwith the provided enumType's values as choices
-