public class RandomValues extends Object
Generated values are always uniformly distributed in pseudorandom fashion.
Can generate both Value and "raw" instances. The "raw" type of a value type means
the corresponding Core API type if such type exists. For example, String[] is the raw type of TextArray.
The length of strings will be governed by RandomValues.Configuration.stringMinLength() and
RandomValues.Configuration.stringMaxLength() and
the length of arrays will be governed by RandomValues.Configuration.arrayMinLength() and
RandomValues.Configuration.arrayMaxLength()
unless method provide explicit arguments for those configurations in which case the provided argument will be used instead.
| Modifier and Type | Class and Description |
|---|---|
static interface |
RandomValues.Configuration |
static class |
RandomValues.Default |
| Modifier and Type | Field and Description |
|---|---|
static RandomValues.Configuration |
DEFAULT_CONFIGURATION |
static int |
MAX_BMP_CODE_POINT |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
among(List<T> among)
Returns a random element of the provided list
|
<T> void |
among(List<T> among,
Consumer<T> action)
Picks a random element of the provided list and feeds it to the provided
Consumer |
<T> T |
among(T[] among)
Returns a random element from the provided array.
|
static RandomValues |
create()
Create a
RandomValues with default configuration |
static RandomValues |
create(Random random)
Create a
RandomValues using the given Random with default configuration |
static RandomValues |
create(Random random,
RandomValues.Configuration configuration)
Create a
RandomValues using the given Random with given configuration |
static RandomValues |
create(RandomValues.Configuration configuration)
Create a
RandomValues with the given configuration |
static RandomValues |
create(SplittableRandom random)
Create a
RandomValues using the given SplittableRandom with default configuration |
static RandomValues |
create(SplittableRandom random,
RandomValues.Configuration configuration)
Create a
RandomValues using the given SplittableRandom with given configuration |
static ValueType[] |
excluding(ValueType... exclude)
Create an array containing all value types, excluding provided types.
|
static ValueType[] |
excluding(ValueType[] among,
Predicate<ValueType> exclude) |
static ValueType[] |
excluding(ValueType[] among,
ValueType... exclude) |
static ValueType[] |
including(Predicate<ValueType> include) |
int |
intBetween(int min,
int max)
Returns an
int between the given lower bound (inclusive) and the upper bound (inclusive) |
String[] |
nextAlphaNumericStringArrayRaw(int minLength,
int maxLength,
int minStringLength,
int maxStringLength) |
TextArray |
nextAlphaNumericTextArray() |
TextValue |
nextAlphaNumericTextValue() |
TextValue |
nextAlphaNumericTextValue(int minLength,
int maxLength) |
ArrayValue |
nextArray()
Returns the next
ArrayValue, distributed uniformly among all array types. |
TextValue |
nextAsciiTextValue() |
TextValue |
nextAsciiTextValue(int minLength,
int maxLength) |
TextArray |
nextBasicMultilingualPlaneTextArray() |
TextValue |
nextBasicMultilingualPlaneTextValue() |
boolean |
nextBoolean() |
BooleanArray |
nextBooleanArray() |
boolean[] |
nextBooleanArrayRaw(int minLength,
int maxLength) |
BooleanValue |
nextBooleanValue() |
ByteArray |
nextByteArray() |
ByteArray |
nextByteArray(int minLength,
int maxLength) |
byte[] |
nextByteArrayRaw(int minLength,
int maxLength) |
ByteValue |
nextByteValue() |
ByteValue |
nextByteValue(byte bound)
Returns the next
ByteValue between 0 (inclusive) and the specified value (exclusive) |
GeoPointValue |
nextCartesianPoint() |
CharArray |
nextCharArray() |
char |
nextCharRaw() |
CharValue |
nextCharValue() |
DateArray |
nextDateArray() |
LocalDate[] |
nextDateArrayRaw(int minLength,
int maxLength) |
DateTimeArray |
nextDateTimeArray() |
ZonedDateTime[] |
nextDateTimeArrayRaw(int minLength,
int maxLength) |
DateTimeValue |
nextDateTimeValue() |
DateTimeValue |
nextDateTimeValue(ZoneId zoneId) |
DateValue |
nextDateValue() |
double |
nextDouble()
Returns the next
double between 0 (inclusive) and 1.0 (exclusive) |
DoubleArray |
nextDoubleArray() |
double[] |
nextDoubleArrayRaw(int minLength,
int maxLength) |
DoubleValue |
nextDoubleValue() |
DurationValue |
nextDuration() |
DurationArray |
nextDurationArray() |
Duration[] |
nextDurationArrayRaw(int minLength,
int maxLength) |
float |
nextFloat()
Returns the next
float between 0 (inclusive) and 1.0 (exclusive) |
FloatArray |
nextFloatArray() |
float[] |
nextFloatArrayRaw(int minLength,
int maxLength) |
FloatValue |
nextFloatValue()
Returns the next
FloatValue between 0 (inclusive) and 1.0 (exclusive) |
GeoPointValue |
nextGeographicPoint() |
int |
nextInt() |
int |
nextInt(int bound)
Returns the next
int between 0 (inclusive) and the specified value (exclusive) |
IntArray |
nextIntArray() |
int[] |
nextIntArrayRaw(int minLength,
int maxLength) |
IntValue |
nextIntValue() |
IntValue |
nextIntValue(int bound)
Returns the next
IntValue between 0 (inclusive) and the specified value (exclusive) |
LocalDateTimeArray |
nextLocalDateTimeArray() |
LocalDateTime[] |
nextLocalDateTimeArrayRaw(int minLength,
int maxLength) |
LocalDateTimeValue |
nextLocalDateTimeValue() |
LocalTimeArray |
nextLocalTimeArray() |
LocalTime[] |
nextLocalTimeArrayRaw(int minLength,
int maxLength) |
LocalTimeValue |
nextLocalTimeValue() |
long |
nextLong() |
long |
nextLong(long bound)
Returns the next
long between 0 (inclusive) and the specified value (exclusive) |
LongArray |
nextLongArray() |
long[] |
nextLongArrayRaw(int minLength,
int maxLength) |
LongValue |
nextLongValue() |
LongValue |
nextLongValue(long bound)
Returns the next
LongValue between 0 (inclusive) and the specified value (exclusive) |
LongValue |
nextLongValue(long lower,
long upper)
Returns the next
LongValue between the specified lower bound (inclusive) and the specified upper bound (inclusive) |
NumberValue |
nextNumberValue() |
DurationValue |
nextPeriod() |
Period[] |
nextPeriodArrayRaw(int minLength,
int maxLength) |
GeoPointValue |
nextPointValue()
Returns a randomly selected point value spread uniformly over the supported types of points.
|
ShortArray |
nextShortArray() |
short[] |
nextShortArrayRaw(int minLength,
int maxLength) |
ShortValue |
nextShortValue() |
ShortValue |
nextShortValue(short bound)
Returns the next
ShortValue between 0 (inclusive) and the specified value (exclusive) |
String[] |
nextStringArrayRaw(int minLength,
int maxLength,
int minStringLength,
int maxStringLength) |
Value |
nextTemporalValue()
Returns a randomly selected temporal value spread uniformly over the supported types.
|
TextArray |
nextTextArray() |
TextValue |
nextTextValue() |
TextValue |
nextTextValue(int minLength,
int maxLength) |
TimeArray |
nextTimeArray() |
OffsetTime[] |
nextTimeArrayRaw(int minLength,
int maxLength) |
TimeValue |
nextTimeValue() |
Value |
nextValue()
Returns the next
Value, distributed uniformly among the supported Value types. |
Value |
nextValueOfType(ValueType type)
Returns the next
Value of provided type. |
Value |
nextValueOfTypes(ValueType... types)
Returns the next
Value, distributed uniformly among the provided value types. |
<T> T[] |
selection(T[] among,
int min,
int max,
boolean allowDuplicates)
Returns a random selection of the provided array.
|
static ValueType[] |
typesOfGroup(ValueGroup valueGroup) |
public static final int MAX_BMP_CODE_POINT
public static final RandomValues.Configuration DEFAULT_CONFIGURATION
public static RandomValues create()
RandomValues with default configurationRandomValues instancepublic static RandomValues create(RandomValues.Configuration configuration)
RandomValues with the given configurationRandomValues instancepublic static RandomValues create(Random random, RandomValues.Configuration configuration)
RandomValues using the given Random with given configurationRandomValues instancepublic static RandomValues create(Random random)
RandomValues using the given Random with default configurationRandomValues instancepublic static RandomValues create(SplittableRandom random, RandomValues.Configuration configuration)
RandomValues using the given SplittableRandom with given configurationRandomValues instancepublic static RandomValues create(SplittableRandom random)
RandomValues using the given SplittableRandom with default configurationRandomValues instancepublic Value nextValue()
Value, distributed uniformly among the supported Value types.RandomValuespublic Value nextValueOfTypes(ValueType... types)
Value, distributed uniformly among the provided value types.RandomValuespublic static ValueType[] excluding(ValueType... exclude)
public static ValueType[] typesOfGroup(ValueGroup valueGroup)
public Value nextValueOfType(ValueType type)
Value of provided type.RandomValuespublic ArrayValue nextArray()
ArrayValue, distributed uniformly among all array types.RandomValuespublic BooleanValue nextBooleanValue()
RandomValuespublic boolean nextBoolean()
RandomValuespublic ByteValue nextByteValue()
RandomValuespublic ByteValue nextByteValue(byte bound)
ByteValue between 0 (inclusive) and the specified value (exclusive)bound - the upper bound (exclusive). Must be positive.ByteValuepublic ShortValue nextShortValue()
RandomValuespublic ShortValue nextShortValue(short bound)
ShortValue between 0 (inclusive) and the specified value (exclusive)bound - the upper bound (exclusive). Must be positive.ShortValuepublic IntValue nextIntValue()
RandomValuespublic int nextInt()
RandomValuespublic IntValue nextIntValue(int bound)
IntValue between 0 (inclusive) and the specified value (exclusive)bound - the upper bound (exclusive). Must be positive.IntValueRandomValuespublic int nextInt(int bound)
int between 0 (inclusive) and the specified value (exclusive)bound - the upper bound (exclusive). Must be positive.intRandomValuespublic int intBetween(int min,
int max)
int between the given lower bound (inclusive) and the upper bound (inclusive)min - minimum value that can be chosen (inclusive)max - maximum value that can be chosen (inclusive)int in the given inclusive range.RandomValuespublic long nextLong()
RandomValuespublic long nextLong(long bound)
long between 0 (inclusive) and the specified value (exclusive)bound - the upper bound (exclusive). Must be positive.longRandomValuespublic LongValue nextLongValue()
RandomValuespublic LongValue nextLongValue(long bound)
LongValue between 0 (inclusive) and the specified value (exclusive)bound - the upper bound (exclusive). Must be positive.LongValueRandomValuespublic LongValue nextLongValue(long lower, long upper)
LongValue between the specified lower bound (inclusive) and the specified upper bound (inclusive)lower - the lower bound (inclusive).upper - the upper bound (inclusive).LongValueRandomValuespublic FloatValue nextFloatValue()
FloatValue between 0 (inclusive) and 1.0 (exclusive)FloatValueRandomValuespublic float nextFloat()
float between 0 (inclusive) and 1.0 (exclusive)floatRandomValuespublic DoubleValue nextDoubleValue()
RandomValuespublic double nextDouble()
double between 0 (inclusive) and 1.0 (exclusive)floatRandomValuespublic NumberValue nextNumberValue()
RandomValuespublic CharValue nextCharValue()
public char nextCharRaw()
public TextValue nextAlphaNumericTextValue()
TextValue consisting only of ascii alphabetic and numerical characters.RandomValuespublic TextValue nextAlphaNumericTextValue(int minLength, int maxLength)
minLength - the minimum length of the stringmaxLength - the maximum length of the stringTextValue consisting only of ascii alphabetic and numerical characters.RandomValuespublic TextValue nextAsciiTextValue()
TextValue consisting only of ascii characters.RandomValuespublic TextValue nextAsciiTextValue(int minLength, int maxLength)
minLength - the minimum length of the stringmaxLength - the maximum length of the stringTextValue consisting only of ascii characters.RandomValuespublic TextValue nextBasicMultilingualPlaneTextValue()
TextValue consisting only of characters in the Basic Multilingual Plane(BMP).RandomValuespublic TextValue nextTextValue()
RandomValuespublic TextValue nextTextValue(int minLength, int maxLength)
minLength - the minimum length of the stringmaxLength - the maximum length of the stringTextValue.RandomValuespublic TimeValue nextTimeValue()
RandomValuespublic LocalDateTimeValue nextLocalDateTimeValue()
RandomValuespublic DateValue nextDateValue()
RandomValuespublic LocalTimeValue nextLocalTimeValue()
RandomValuespublic DateTimeValue nextDateTimeValue()
RandomValuespublic DateTimeValue nextDateTimeValue(ZoneId zoneId)
RandomValuespublic DurationValue nextPeriod()
DurationValue based on java Period (years, months and days).RandomValuespublic DurationValue nextDuration()
DurationValue based on java Duration (seconds, nanos).RandomValuespublic Value nextTemporalValue()
public GeoPointValue nextCartesianPoint()
PointValue.RandomValuespublic GeoPointValue nextGeographicPoint()
RandomValuespublic GeoPointValue nextPointValue()
public CharArray nextCharArray()
public DoubleArray nextDoubleArray()
RandomValuespublic double[] nextDoubleArrayRaw(int minLength,
int maxLength)
RandomValuespublic FloatArray nextFloatArray()
RandomValuespublic float[] nextFloatArrayRaw(int minLength,
int maxLength)
RandomValuespublic LongArray nextLongArray()
RandomValuespublic long[] nextLongArrayRaw(int minLength,
int maxLength)
RandomValuespublic IntArray nextIntArray()
RandomValuespublic int[] nextIntArrayRaw(int minLength,
int maxLength)
RandomValuespublic ByteArray nextByteArray()
RandomValuespublic ByteArray nextByteArray(int minLength, int maxLength)
RandomValuespublic byte[] nextByteArrayRaw(int minLength,
int maxLength)
RandomValuespublic ShortArray nextShortArray()
RandomValuespublic short[] nextShortArrayRaw(int minLength,
int maxLength)
RandomValuespublic BooleanArray nextBooleanArray()
RandomValuespublic boolean[] nextBooleanArrayRaw(int minLength,
int maxLength)
RandomValuespublic TextArray nextAlphaNumericTextArray()
TextArray containing strings with only alpha-numeric characters.RandomValuespublic String[] nextAlphaNumericStringArrayRaw(int minLength, int maxLength, int minStringLength, int maxStringLength)
String[] containing strings with only alpha-numeric characters.RandomValuespublic TextArray nextBasicMultilingualPlaneTextArray()
TextArray containing strings with only characters in the Basic Multilingual Plane (BMP).RandomValuespublic TextArray nextTextArray()
RandomValuespublic String[] nextStringArrayRaw(int minLength, int maxLength, int minStringLength, int maxStringLength)
RandomValuespublic LocalTimeArray nextLocalTimeArray()
RandomValuespublic LocalTime[] nextLocalTimeArrayRaw(int minLength, int maxLength)
RandomValuespublic TimeArray nextTimeArray()
RandomValuespublic OffsetTime[] nextTimeArrayRaw(int minLength, int maxLength)
RandomValuespublic DateTimeArray nextDateTimeArray()
RandomValuespublic ZonedDateTime[] nextDateTimeArrayRaw(int minLength, int maxLength)
RandomValuespublic LocalDateTimeArray nextLocalDateTimeArray()
RandomValuespublic LocalDateTime[] nextLocalDateTimeArrayRaw(int minLength, int maxLength)
RandomValuespublic DateArray nextDateArray()
RandomValuespublic LocalDate[] nextDateArrayRaw(int minLength, int maxLength)
RandomValuespublic Period[] nextPeriodArrayRaw(int minLength, int maxLength)
RandomValuespublic DurationArray nextDurationArray()
DurationValue based on java Duration (seconds, nanos).RandomValuespublic Duration[] nextDurationArrayRaw(int minLength, int maxLength)
RandomValuespublic <T> T among(T[] among)
among - the array to choose a random element from.public <T> T among(List<T> among)
among - the list to choose a random element frompublic <T> void among(List<T> among, Consumer<T> action)
Consumeramong - the list to pick fromaction - the consumer to feed values topublic <T> T[] selection(T[] among,
int min,
int max,
boolean allowDuplicates)
among - the array to pick elements frommin - the minimum number of elements to choosemax - the maximum number of elements to chooseallowDuplicates - if true the same element can be chosen multiple timesCopyright © 2016–2021 MWARE SOLUTIONS. All rights reserved.