Skip to content

//core/io.github.serpro69.kfaker.provider.misc/RandomProvider

RandomProvider

[jvm]\ class RandomProvider : AbstractFakeDataProvider<RandomProvider> , IRandom

Provides data-generator-like functionality for the functions of RandomService.

Types

Name Summary
Key [jvm]
enum Key : Enum<RandomProvider.Key>
Keys for unique data provider to simplify resetting unique values via RandomProvider.clear function.

Properties

Name Summary
config [jvm]
open override val config: FakerConfig
unique [jvm]
open override val unique: RandomProvider
An instance of T for generating unique values

Functions

Name Summary
clear [jvm]
fun clear(name: String)
Clears used unique values for the function name of this provider.
[jvm]
fun clear(key: RandomProvider.Key)
Clears used unique values for the function key of this provider.
clearAll [jvm]
fun clearAll()
Clears all used unique values of this provider.
nextBoolean [jvm]
open override fun nextBoolean(): Boolean
Returns the next pseudorandom, uniformly distributed Boolean value from this random number generator's sequence.
nextChar [jvm]
open override fun nextChar(): Char
Returns the next pseudorandom, uniformly distributed Char value, from this random number generator's sequence.
nextDouble [jvm]
open override fun nextDouble(): Double
Returns the next pseudorandom, uniformly distributed Double value between 0.0 and 1.0 from this random number generator's sequence.
nextEnum [jvm]
inline fun <E : Enum<E>> nextEnum(): E
Returns a randomly selected enum entry of type E.
[jvm]
open override fun <E : Enum<E>> nextEnum(enum: Class<E>): E
Returns a pseudo-randomly selected enum entry of type E.
[jvm]
open override fun <E : Enum<E>> nextEnum(values: Array<E>): E
Returns a pseudo-randomly selected enum entry from an Array of E type values.
[jvm]
inline 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.
[jvm]
open override 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.
nextFloat [jvm]
open override fun nextFloat(): Float
Returns the next pseudorandom, uniformly distributed Float value between 0.0 and 1.0 from this random number generator's sequence.
nextInt [jvm]
open override fun nextInt(): Int
Returns the next pseudorandom, uniformly distributed Int value from this random number generator's sequence.
[jvm]
open override 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.
[jvm]
open override 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.
[jvm]
open override 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.
nextLetter [jvm]
open override fun nextLetter(upper: Boolean): Char
Returns the next pseudorandom, uniformly distributed Char value that corresponds to a letter in the English alphabet.
nextLong [jvm]
open override fun nextLong(): Long
Returns the next pseudorandom, uniformly distributed Long value from this random number generator's sequence.
[jvm]
open override 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.
[jvm]
open override 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.
[jvm]
open override 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.
nextUUID [jvm]
open override fun nextUUID(): String
Returns the next pseudorandom UUID as String taking the seed of this random.
randomDate [jvm]
open override 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
randomFutureDate [jvm]
open override fun randomFutureDate(): OffsetDateTime
Returns a pseudorandom, uniformly distributed OffsetDateTime value between now (exclusive) and now + 50 years (inclusive) using UTC zone offset
[jvm]
open override fun randomFutureDate(max: Instant): OffsetDateTime
Returns a pseudorandom, uniformly distributed OffsetDateTime value between now (exclusive) and max (inclusive) using UTC zone offset
randomPastDate [jvm]
open override 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
[jvm]
open override fun randomPastDate(min: Instant): OffsetDateTime
Returns a pseudorandom, uniformly distributed OffsetDateTime value between min (inclusive) and now (exclusive) using UTC zone offset
randomString [jvm]
open override 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.
[jvm]
open override 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
[jvm]
open override 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
randomSublist [jvm]
open override fun <T> randomSublist(list: List<T>, size: Int, shuffled: Boolean): List<T>
open override 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.
randomSubset [jvm]
open override fun <T> randomSubset(set: Set<T>, size: Int, shuffled: Boolean): Set<T>
open override 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.
randomValue [jvm]
open override fun <T> randomValue(array: Array<T>): T
Returns a pseudo-randomly selected value from the array of values.
[jvm]
open override fun <T> randomValue(list: List<T>): T
Returns a pseudo-randomly selected value from the list of values.