Package net.datafaker.providers.base
Class Options
- Since:
- 0.8.0
-
Field Summary
Fields inherited from class net.datafaker.providers.base.AbstractProvider
faker
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<E> E
nextElement
(E[] array) Returns a random element from an array.<E> E
nextElement
(List<E> list) Returns a random element from a list.final <E> E
option
(E... options) Returns a random element from an varargs.<E extends Enum<E>>
EReturns a random element from Enum.Returns a random String element from an varargs.final <E> Set<E>
subset
(int size, E... options) Returns a random unique subset of elements from an varargs.Returns a random unique subset of elements from an varargs.
-
Constructor Details
-
Options
-
-
Method Details
-
option
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
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
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
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
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
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.
-