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
Constructors -
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 boolean
option
(boolean[] options) final byte
option
(byte[] options) final char
option
(char[] options) final double
option
(double[] options) final float
option
(float[] options) final int
option
(int[] options) final long
option
(long[] options) final short
option
(short[] options) 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.Methods inherited from class net.datafaker.providers.base.AbstractProvider
equals, getFaker, hashCode, loadGenerators, resolve, resolve, toString
-
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.
-
option
public final char option(char[] options) -
option
public final int option(int[] options) -
option
public final long option(long[] options) -
option
public final float option(float[] options) -
option
public final double option(double[] options) -
option
public final short option(short[] options) -
option
public final boolean option(boolean[] options) -
option
public final byte option(byte[] options) -
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.
-