@@ -9,11 +9,23 @@ protected Options(Faker faker) {
9
9
this .faker = faker ;
10
10
}
11
11
12
-
13
- public String option (String ... options ) {
12
+ /**
13
+ * Returns a random element from an varargs.
14
+ *
15
+ * @param options The varargs to take a random element from.
16
+ * @param <E> The type of the elements in the varargs.
17
+ * @return A randomly selected element from the varargs.
18
+ */
19
+ public <E > E option (E ... options ) {
14
20
return options [faker .random ().nextInt (options .length )];
15
21
}
16
22
23
+ /**
24
+ * Returns a random element from Enum.
25
+ *
26
+ * @param enumeration The Enum to take a random element from.
27
+ * @return A randomly selected element from the enum.
28
+ */
17
29
public <E extends Enum <E >> E option (Class <E > enumeration ) {
18
30
E [] enumConstants = enumeration .getEnumConstants ();
19
31
return enumConstants [faker .random ().nextInt (enumConstants .length )];
@@ -22,7 +34,7 @@ public <E extends Enum<E>> E option(Class<E> enumeration) {
22
34
/**
23
35
* Returns a random element from an array.
24
36
*
25
- * @param array The array to take a random element fom .
37
+ * @param array The array to take a random element from .
26
38
* @param <E> The type of the elements in the array.
27
39
* @return A randomly selected element from the array.
28
40
*/
@@ -33,7 +45,7 @@ public <E> E nextElement(E[] array) {
33
45
/**
34
46
* Returns a random element from a list.
35
47
*
36
- * @param list The list to take a random element fom .
48
+ * @param list The list to take a random element from .
37
49
* @param <E> The type of the elements in the list.
38
50
* @return A randomly selected element from the list.
39
51
*/
0 commit comments