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
Modifier and TypeClassDescriptionstatic class
Randomly 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 choicesEnum
class.static <T> T
anyOf
(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> T
anyOf
(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
- aCollection
of 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
- aCollection
of 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 choicesEnum
class. -
aChoiceFrom
- Type Parameters:
T
- the type of the choices- Parameters:
choices
- aCollection
of choices- Returns:
- a new
RandomChoice.Builder
with the provided choices
-
aChoiceFrom
- Type Parameters:
K
- the type of the choices' keysV
- the type of the choices' values- Parameters:
choices
- aCollection
of choices- Returns:
- a new
RandomChoice.Builder
with the provided choices
-
aChoiceFrom
- Type Parameters:
T
- the type of the choices- Parameters:
choices
- an array of choices- Returns:
- a new
RandomChoice.Builder
with 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
- theEnum
type- Returns:
- a new
RandomChoice.Builder
with the provided enumType's values as choices
-