interface IRandom: Any
Fields
Name | Description |
---|---|
abstract config: FakerConfig
|
Methods
nextInt
abstract fun nextInt(): Int
Returns the next pseudorandom, uniformly distributed Int value from this random number generator's sequence.
ReturnValue
Name | Description |
---|---|
Int
|
nextInt
abstract fun nextInt(bound: Int): Int
Returns a pseudorandom, uniformly distributed Int value between 0
(inclusive)
and the specified bound (exclusive),
drawn from this random number generator's sequence.
Parameters
Name | Description |
---|---|
bound: Int
|
ReturnValue
Name | Description |
---|---|
Int
|
nextInt
abstract fun nextInt(intRange: IntRange): Int
Returns a pseudorandom, uniformly distributed Int value within the specified int range (inclusive), drawn from this random number generator's sequence.
Parameters
Name | Description |
---|---|
intRange: IntRange
|
ReturnValue
Name | Description |
---|---|
Int
|
nextInt
abstract fun nextInt(min: Int, max: Int): Int
Returns a pseudorandom, uniformly distributed Int value between min (inclusive) and max (inclusive), drawn from this random number generator's sequence.
Parameters
Name | Description |
---|---|
min: Int
|
|
max: Int
|
ReturnValue
Name | Description |
---|---|
Int
|
randomValue
abstract fun <T> randomValue(list: List<T>): T
Returns a pseudo-randomly selected value from the list of values.
Parameters
Name | Description |
---|---|
list: List<T>
|
ReturnValue
Name | Description |
---|---|
T
|
randomValue
abstract fun <T> randomValue(array: Array<T>): T
Returns a pseudo-randomly selected value from the array of values.
Parameters
Name | Description |
---|---|
array: Array<T>
|
ReturnValue
Name | Description |
---|---|
T
|
nextLetter
abstract fun nextLetter(upper: Boolean): Char
Returns the next pseudorandom, uniformly distributed Char value that corresponds to a letter in the English alphabet.
Parameters
Name | Description |
---|---|
upper: Boolean
|
returns the Char in upper-case if set to |
ReturnValue
Name | Description |
---|---|
Char
|
randomString
abstract fun randomString(length: Int, numericalChars: Boolean): String
Returns String with the specified length consisting of a pseudo-randomly generated
English alphabet letters and optional numericalChars,
or an empty string for a length < 1
.
Parameters
Name | Description |
---|---|
length: Int
|
the length of the resulting string.
Default: |
numericalChars: Boolean
|
add additional numerical chars from 0 to 9 to the resulting string.
Default: |
ReturnValue
Name | Description |
---|---|
String
|
randomString
abstract fun randomString(length: Int, locale: Locale, indexChars: Boolean, auxiliaryChars: Boolean, punctuationChars: Boolean, numericalChars: Boolean): String
Returns String with the specified length (or an empty string for a length < 1
)
consisting of pseudo-randomly generated characters
in a given locale with optional auxiliaryChars and numericalChars
Parameters
Name | Description |
---|---|
length: Int
|
the length of the resulting string.
Default: |
locale: Locale
|
locale to use to generate the charset.
Defaults to |
indexChars: Boolean
|
add additional index chars to the resulting string, as defined in
Character_Elements.
Default: |
auxiliaryChars: Boolean
|
add additional auxiliary chars to the resulting string as defined in
Character_Elements.
Default: |
punctuationChars: Boolean
|
|
numericalChars: Boolean
|
add additional numerical chars from 0 to 9 to the resulting string
Default: |
ReturnValue
Name | Description |
---|---|
String
|
randomString
abstract fun randomString(min: Int, max: Int, locale: Locale, indexChars: Boolean, auxiliaryChars: Boolean, punctuationChars: Boolean, numericalChars: Boolean): String
Returns String with a randomLength withing the specified min and max boundaries
(or an empty string for if randomLength < 1
)
consisting of pseudo-randomly generated characters
in a given locale with optional auxiliaryChars and numericalChars
Parameters
Name | Description |
---|---|
min: Int
|
the minimum length of the resulting string. |
max: Int
|
the maximum length of the resulting string. |
locale: Locale
|
locale to use to generate the charset.
Defaults to |
indexChars: Boolean
|
add additional index chars to the resulting string, as defined in
Character_Elements.
Default: |
auxiliaryChars: Boolean
|
add additional auxiliary chars to the resulting string as defined in
Character_Elements.
Default: |
punctuationChars: Boolean
|
|
numericalChars: Boolean
|
add additional numerical chars from 0 to 9 to the resulting string
Default: |
ReturnValue
Name | Description |
---|---|
String
|
nextBoolean
abstract fun nextBoolean(): Boolean
Returns the next pseudorandom, uniformly distributed Boolean value from this random number generator's sequence.
The values true
and false
are produced with (approximately) equal probability.
ReturnValue
Name | Description |
---|---|
Boolean
|
nextLong
abstract fun nextLong(): Long
Returns the next pseudorandom, uniformly distributed Long value from this random number generator's sequence.
ReturnValue
Name | Description |
---|---|
Long
|
nextLong
abstract fun nextLong(bound: Long): Long
Returns a pseudorandom, uniformly distributed Long value between 0
(inclusive),
and the specified bound value (exclusive),
drawn from this random number generator's sequence.
Parameters
Name | Description |
---|---|
bound: Long
|
ReturnValue
Name | Description |
---|---|
Long
|
nextLong
abstract fun nextLong(longRange: LongRange): Long
Returns a pseudorandom, uniformly distributed Long value within the specified longRange (inclusive), drawn from this random number generator's sequence.
Parameters
Name | Description |
---|---|
longRange: LongRange
|
ReturnValue
Name | Description |
---|---|
Long
|
nextLong
abstract fun nextLong(min: Long, max: Long): Long
Returns a pseudorandom, uniformly distributed Long value between min (inclusive) and max (inclusive), drawn from this random number generator's sequence.
Parameters
Name | Description |
---|---|
min: Long
|
|
max: Long
|
ReturnValue
Name | Description |
---|---|
Long
|
nextFloat
abstract fun nextFloat(): Float
Returns the next pseudorandom, uniformly distributed Float value between 0.0
and 1.0
from this random number generator's sequence.
ReturnValue
Name | Description |
---|---|
Float
|
nextDouble
abstract fun nextDouble(): Double
Returns the next pseudorandom, uniformly distributed Double value between 0.0
and 1.0
from this random number generator's sequence.
ReturnValue
Name | Description |
---|---|
Double
|
nextChar
abstract fun nextChar(): Char
Returns the next pseudorandom, uniformly distributed Char value, from this random number generator's sequence.
ReturnValue
Name | Description |
---|---|
Char
|
nextEnum
abstract fun <E : Enum<E>> nextEnum(enum: Class<E>): E
Returns a pseudo-randomly selected enum entry of type E.
Parameters
Name | Description |
---|---|
enum: Class<E>
|
ReturnValue
Name | Description |
---|---|
E
|
nextEnum
abstract fun <E : Enum<E>> nextEnum(values: Array<E>): E
Returns a pseudo-randomly selected enum entry from an Array of E type values.
Parameters
Name | Description |
---|---|
values: Array<E>
|
ReturnValue
Name | Description |
---|---|
E
|
nextEnum
abstract fun <E : Enum<E>> nextEnum(enum: Class<E>, predicate: (E)->Boolean): E
Returns a pseudo-randomly selected enum class of type E based on predicate for E.
Parameters
Name | Description |
---|---|
enum: Class<E>
|
|
predicate: (E)->Boolean
|
ReturnValue
Name | Description |
---|---|
E
|
nextUUID
abstract fun nextUUID(): String
ReturnValue
Name | Description |
---|---|
String
|
randomSublist
abstract fun <T> randomSublist(list: List<T>, size: Int, shuffled: Boolean): List<T>
Returns a view of the portion of the list
with pseudo-randomly generated fromIndex
and (possibly) toIndex
values.
Parameters
Name | Description |
---|---|
list: List<T>
|
|
size: Int
|
the desired size of the resulting list.
If |
shuffled: Boolean
|
if |
ReturnValue
Name | Description |
---|---|
List<T>
|
randomSublist
abstract fun <T> randomSublist(list: List<T>, sizeRange: IntRange, shuffled: Boolean): List<T>
Returns a view of the portion of the list
with pseudo-randomly generated fromIndex
and (possibly) toIndex
values.
Parameters
Name | Description |
---|---|
list: List<T>
|
|
sizeRange: IntRange
|
the desired size range of the resulting list.
The |
shuffled: Boolean
|
if |
ReturnValue
Name | Description |
---|---|
List<T>
|
randomSubset
abstract fun <T> randomSubset(set: Set<T>, size: Int, shuffled: Boolean): Set<T>
Returns a portion of the set
with pseudo-randomly generated fromIndex
and (possibly) toIndex
values.
Parameters
Name | Description |
---|---|
set: Set<T>
|
|
size: Int
|
the desired size of the resulting set.
If |
shuffled: Boolean
|
if |
ReturnValue
Name | Description |
---|---|
Set<T>
|
randomSubset
abstract fun <T> randomSubset(set: Set<T>, sizeRange: IntRange, shuffled: Boolean): Set<T>
Returns a portion of the set
with pseudo-randomly generated fromIndex
and (possibly) toIndex
values.
Parameters
Name | Description |
---|---|
set: Set<T>
|
|
sizeRange: IntRange
|
the desired size range of the resulting list.
The |
shuffled: Boolean
|
if |
ReturnValue
Name | Description |
---|---|
Set<T>
|
randomPastDate
abstract fun randomPastDate(): OffsetDateTime
Returns a pseudorandom, uniformly distributed OffsetDateTime value between Unix epoch (1970-01-01T00:00:00Z) (inclusive) and now (exclusive) using UTC zone offset
ReturnValue
Name | Description |
---|---|
OffsetDateTime
|
randomPastDate
abstract fun randomPastDate(min: Instant): OffsetDateTime
Returns a pseudorandom, uniformly distributed OffsetDateTime value between min (inclusive) and now (exclusive) using UTC zone offset
Parameters
Name | Description |
---|---|
min: Instant
|
ReturnValue
Name | Description |
---|---|
OffsetDateTime
|
randomFutureDate
abstract fun randomFutureDate(): OffsetDateTime
Returns a pseudorandom, uniformly distributed OffsetDateTime value between now (exclusive) and now + 50 years (inclusive) using UTC zone offset
ReturnValue
Name | Description |
---|---|
OffsetDateTime
|
randomFutureDate
abstract fun randomFutureDate(max: Instant): OffsetDateTime
Returns a pseudorandom, uniformly distributed OffsetDateTime value between now (exclusive) and max (inclusive) using UTC zone offset
Parameters
Name | Description |
---|---|
max: Instant
|
ReturnValue
Name | Description |
---|---|
OffsetDateTime
|
randomDate
abstract fun randomDate(min: Instant, max: Instant, zoneOffset: ZoneOffset): OffsetDateTime
Returns a pseudorandom, uniformly distributed OffsetDateTime value between min (inclusive) and max (inclusive) using the defined zoneOffset
Parameters
Name | Description |
---|---|
min: Instant
|
|
max: Instant
|
|
zoneOffset: ZoneOffset
|
ReturnValue
Name | Description |
---|---|
OffsetDateTime
|
Provides functionality similar to Random