class RandomProvider: AbstractFakeDataProvider<RandomProvider>
Fields
Name | Description |
---|---|
protected category: Category
|
Category of |
protected localUniqueDataProvider: LocalUniqueDataProvider<RandomProvider>
|
A LocalUniqueDataProvider instance that is used with this unique provider. |
val unique: RandomProvider
|
An instance of T for generating unique values |
val config: FakerConfig
|
Methods
clear
fun clear(key: Key)
Clears used unique values for the function key of this provider.
Parameters
Name | Description |
---|---|
key: Key
|
ReturnValue
Name | Description |
---|---|
Unit
|
nextInt
fun nextInt(): Int
ReturnValue
Name | Description |
---|---|
Int
|
nextInt
fun nextInt(bound: Int): Int
Parameters
Name | Description |
---|---|
bound: Int
|
ReturnValue
Name | Description |
---|---|
Int
|
nextInt
fun nextInt(intRange: IntRange): Int
Parameters
Name | Description |
---|---|
intRange: IntRange
|
ReturnValue
Name | Description |
---|---|
Int
|
nextInt
fun nextInt(min: Int, max: Int): Int
Parameters
Name | Description |
---|---|
min: Int
|
|
max: Int
|
ReturnValue
Name | Description |
---|---|
Int
|
randomValue
fun <T> randomValue(list: List<T>): T
Parameters
Name | Description |
---|---|
list: List<T>
|
ReturnValue
Name | Description |
---|---|
T
|
randomValue
fun <T> randomValue(array: Array<T>): T
Parameters
Name | Description |
---|---|
array: Array<T>
|
ReturnValue
Name | Description |
---|---|
T
|
nextLetter
fun nextLetter(upper: Boolean): Char
Parameters
Name | Description |
---|---|
upper: Boolean
|
ReturnValue
Name | Description |
---|---|
Char
|
randomString
fun randomString(length: Int, numericalChars: Boolean): String
Parameters
Name | Description |
---|---|
length: Int
|
|
numericalChars: Boolean
|
ReturnValue
Name | Description |
---|---|
String
|
randomString
fun randomString(length: Int, locale: Locale, indexChars: Boolean, auxiliaryChars: Boolean, punctuationChars: Boolean, numericalChars: Boolean): String
Parameters
Name | Description |
---|---|
length: Int
|
|
locale: Locale
|
|
indexChars: Boolean
|
|
auxiliaryChars: Boolean
|
|
punctuationChars: Boolean
|
|
numericalChars: Boolean
|
ReturnValue
Name | Description |
---|---|
String
|
randomString
fun randomString(min: Int, max: Int, locale: Locale, indexChars: Boolean, auxiliaryChars: Boolean, punctuationChars: Boolean, numericalChars: Boolean): String
Parameters
Name | Description |
---|---|
min: Int
|
|
max: Int
|
|
locale: Locale
|
|
indexChars: Boolean
|
|
auxiliaryChars: Boolean
|
|
punctuationChars: Boolean
|
|
numericalChars: Boolean
|
ReturnValue
Name | Description |
---|---|
String
|
nextBoolean
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.
NB! this method does not try to produce "unique" values via unique data provider.
ReturnValue
Name | Description |
---|---|
Boolean
|
nextLong
fun nextLong(): Long
ReturnValue
Name | Description |
---|---|
Long
|
nextLong
fun nextLong(bound: Long): Long
Parameters
Name | Description |
---|---|
bound: Long
|
ReturnValue
Name | Description |
---|---|
Long
|
nextLong
fun nextLong(longRange: LongRange): Long
Parameters
Name | Description |
---|---|
longRange: LongRange
|
ReturnValue
Name | Description |
---|---|
Long
|
nextLong
fun nextLong(min: Long, max: Long): Long
Parameters
Name | Description |
---|---|
min: Long
|
|
max: Long
|
ReturnValue
Name | Description |
---|---|
Long
|
nextFloat
fun nextFloat(): Float
ReturnValue
Name | Description |
---|---|
Float
|
nextDouble
fun nextDouble(): Double
ReturnValue
Name | Description |
---|---|
Double
|
nextChar
fun nextChar(): Char
ReturnValue
Name | Description |
---|---|
Char
|
nextEnum
fun <E : Enum<E>> nextEnum(): E
Returns a randomly selected enum entry of type E.
NB! when used with unique, the nextInt, which is used to get a random index of the enumValues of Ewill also use unique generation and will need to be reset via clear as well when needed.
ReturnValue
Name | Description |
---|---|
E
|
nextEnum
fun <E : Enum<E>> nextEnum(enum: Class<E>): E
Parameters
Name | Description |
---|---|
enum: Class<E>
|
ReturnValue
Name | Description |
---|---|
E
|
nextEnum
fun <E : Enum<E>> nextEnum(values: Array<E>): E
Parameters
Name | Description |
---|---|
values: Array<E>
|
ReturnValue
Name | Description |
---|---|
E
|
nextEnum
fun <E : Enum<E>> nextEnum(enum: Class<E>, predicate: (E)->Boolean): E
Parameters
Name | Description |
---|---|
enum: Class<E>
|
|
predicate: (E)->Boolean
|
ReturnValue
Name | Description |
---|---|
E
|
nextEnum
fun <E : Enum<E>> nextEnum(vararg excludeName: String): E
Returns a randomly selected enum entry of type E excluding a particular enum class by its name.
NB! when used with unique, the nextInt, which is used to get a random index of the enumValues of Ewill also use unique generation and will need to be reset via clear as well when needed.
Parameters
Name | Description |
---|---|
vararg excludeName: String
|
ReturnValue
Name | Description |
---|---|
E
|
nextUUID
fun nextUUID(): String
ReturnValue
Name | Description |
---|---|
String
|
randomSublist
fun <T> randomSublist(list: List<T>, size: Int, shuffled: Boolean): List<T>
Parameters
Name | Description |
---|---|
list: List<T>
|
|
size: Int
|
|
shuffled: Boolean
|
ReturnValue
Name | Description |
---|---|
List<T>
|
randomSublist
fun <T> randomSublist(list: List<T>, sizeRange: IntRange, shuffled: Boolean): List<T>
Parameters
Name | Description |
---|---|
list: List<T>
|
|
sizeRange: IntRange
|
|
shuffled: Boolean
|
ReturnValue
Name | Description |
---|---|
List<T>
|
randomSubset
fun <T> randomSubset(set: Set<T>, size: Int, shuffled: Boolean): Set<T>
Parameters
Name | Description |
---|---|
set: Set<T>
|
|
size: Int
|
|
shuffled: Boolean
|
ReturnValue
Name | Description |
---|---|
Set<T>
|
randomSubset
fun <T> randomSubset(set: Set<T>, sizeRange: IntRange, shuffled: Boolean): Set<T>
Parameters
Name | Description |
---|---|
set: Set<T>
|
|
sizeRange: IntRange
|
|
shuffled: Boolean
|
ReturnValue
Name | Description |
---|---|
Set<T>
|
randomPastDate
fun randomPastDate(): OffsetDateTime
ReturnValue
Name | Description |
---|---|
OffsetDateTime
|
randomPastDate
fun randomPastDate(min: Instant): OffsetDateTime
Parameters
Name | Description |
---|---|
min: Instant
|
ReturnValue
Name | Description |
---|---|
OffsetDateTime
|
randomFutureDate
fun randomFutureDate(): OffsetDateTime
ReturnValue
Name | Description |
---|---|
OffsetDateTime
|
randomFutureDate
fun randomFutureDate(max: Instant): OffsetDateTime
Parameters
Name | Description |
---|---|
max: Instant
|
ReturnValue
Name | Description |
---|---|
OffsetDateTime
|
randomDate
fun randomDate(min: Instant, max: Instant, zoneOffset: ZoneOffset): OffsetDateTime
Parameters
Name | Description |
---|---|
min: Instant
|
|
max: Instant
|
|
zoneOffset: ZoneOffset
|
ReturnValue
Name | Description |
---|---|
OffsetDateTime
|
Provides data-generator-like functionality for the functions of RandomService.