Package-level declarations

Types

Link copied to clipboard
data object Auto

Marker used by generates auto to request Fiktion's automatic generation.

Link copied to clipboard
class CannotGenerateException(message: String, cause: Throwable? = null) : RuntimeException

Thrown when Fiktion cannot generate a value for the requested target.

Link copied to clipboard

Configured generation rule for collection values.

Link copied to clipboard
@RequiresOptIn(message = "This Fiktion API is experimental and may change before 1.0.", level = RequiresOptIn.Level.WARNING)
annotation class ExperimentalFiktionApi

Marks APIs that are expected to evolve before Fiktion reaches 1.0.

Link copied to clipboard
interface FakeContext

Runtime context passed to custom generators.

Link copied to clipboard

Runtime nullability information for a generated property.

Link copied to clipboard
data class FakePath(val segments: List<FakeProperty>)

Runtime path to a generated value.

Link copied to clipboard
data class FakeProperty(val owner: FakeType, val name: String, val type: FakeType, val nullability: FakeNullability)

Runtime description of a generated property.

Link copied to clipboard
class FakeSpec<Root>

Per-call configuration for generating a Root value.

Link copied to clipboard
data class FakeType(val id: String, val displayName: String)

Runtime description of a generated type.

Link copied to clipboard
sealed interface Fiktion

Configured fake data generator.

Link copied to clipboard
interface FiktionAddon

Extension point that contributes reusable Fiktion rules.

Link copied to clipboard

Builder exposed to add-ons for contributing reusable low-precedence rules.

Link copied to clipboard
class FiktionArrayMetadata<T>(val type: KType, val elementType: KType, constructor: (List<Any?>) -> T) : FiktionTypeMetadata<T>

Runtime construction metadata for an array type that Fiktion can generate automatically.

Link copied to clipboard

Builder exposed when creating isolated Fiktion instances.

Link copied to clipboard

Thrown when Fiktion configuration or DSL input is invalid.

Link copied to clipboard

Builder exposed when updating the global Fiktion configuration.

Link copied to clipboard
class FiktionEnumMetadata<T : Enum<T>>(val type: KType, val entries: List<T>) : FiktionTypeMetadata<T>

Runtime construction metadata for an enum type.

Link copied to clipboard
sealed interface FiktionObjectArgument

Constructor argument produced while generating an object.

Link copied to clipboard

Constructor argument marker that asks generated metadata to use the property's default value.

Link copied to clipboard
class FiktionObjectMetadata<T>(val type: KType, val properties: List<FiktionObjectProperty>, constructor: (List<FiktionObjectArgument>) -> T) : FiktionTypeMetadata<T>

Runtime construction metadata for a type that Fiktion can generate automatically.

Link copied to clipboard
data class FiktionObjectProperty(val name: String, val type: KType, val hasDefault: Boolean = false)

Runtime construction metadata for one generated object property.

Link copied to clipboard
data class FiktionObjectValue(val value: Any?) : FiktionObjectArgument

Constructor argument containing a generated value.

Link copied to clipboard
sealed class FiktionRuleBuilder

Shared rule registration surface exposed by Fiktion builders.

Link copied to clipboard
class FiktionSealedMetadata<T>(val type: KType, val subtypes: List<KType>) : FiktionTypeMetadata<T>

Runtime construction metadata for a sealed type.

Link copied to clipboard
sealed interface FiktionSnapshot

Restorable snapshot of the global Fiktion configuration.

Link copied to clipboard
sealed interface FiktionTypeMetadata<T>

Runtime metadata for a type that Fiktion can generate automatically.

Link copied to clipboard
class FiktionValueMetadata<T>(val type: KType, val underlyingType: KType, constructor: (value: Any?) -> T) : FiktionTypeMetadata<T>

Runtime construction metadata for a value-like type backed by one generated value.

Link copied to clipboard
sealed interface GenerationSpec<out T>

Configured generation rule for values of T.

Link copied to clipboard
typealias Generator<T> = FakeContext.() -> T

Custom value generator executed with a FakeContext.

Link copied to clipboard

Configured map rule that defines key and value generation.

Link copied to clipboard

Configured generation rule for map values.

Link copied to clipboard

Partially configured map rule that defines key generation.

Link copied to clipboard

Partially configured map rule that defines value generation.

Link copied to clipboard
value class Probability(val value: Double)

Probability value represented as a number from 0.0 to 1.0.

Link copied to clipboard
class PropertyPath<Root, out Value>

Type-safe path from Root to a nested Value property.

Link copied to clipboard
sealed interface RuleNameTarget

Target selected by a property-name rule before its value type is known.

Link copied to clipboard
sealed interface RuleTarget<T>

Target selected by a rule declaration.

Link copied to clipboard

Context for generating a value from the requested type's type arguments.

Link copied to clipboard

Generator used by type-family rules.

Link copied to clipboard
sealed interface TypeFamilyRuleTarget<T>

Target selected by a type-family rule declaration.

Properties

Link copied to clipboard
val auto: Auto

Requests Fiktion's automatic generation in rule declarations.

Link copied to clipboard

Converts this floating-point percentage to a Probability.

Converts this integer percentage to a Probability.

Functions

Link copied to clipboard

Completes this map rule by generating keys with generator.

Link copied to clipboard

Completes this map rule by generating values with generator.

Link copied to clipboard

Appends next to this property path.

Creates a nested property path using /.

Link copied to clipboard
inline fun <T> fake(seed: Long? = null, noinline configure: FakeSpec<T>.() -> Unit = {}): T

Generates fake data for T using the global Fiktion configuration.

fun <T> fake(type: KType, seed: Long? = null, configure: FakeSpec<T>.() -> Unit = {}): T

Generates fake data for T using the global Fiktion configuration and explicit type.

Link copied to clipboard
inline fun <T> Fiktion.fake(seed: Long? = null, noinline configure: FakeSpec<T>.() -> Unit = {}): T

Generates fake data for T using this Fiktion instance.

fun <T> Fiktion.fake(type: KType, seed: Long? = null, configure: FakeSpec<T>.() -> Unit = {}): T

Generates fake data for T using this Fiktion instance and explicit type.

Link copied to clipboard
inline fun <T> generatedArray(elements: List<Any?>): Array<T>

Creates a typed array from compiler-generated array metadata.

Link copied to clipboard

Returns whether the generated constructor argument at index asks Kotlin to use the property's default value.

Link copied to clipboard

Returns the generated constructor argument value at index.

Link copied to clipboard
infix inline fun <T> RuleNameTarget.generates(value: T): GenerationSpec<T>

Generates value for this name target and infers the target value type from value.

infix fun <T> RuleTarget<T>.generates(value: T): GenerationSpec<T>

Generates value for this rule target.

infix fun <T> RuleTarget<T>.generates(auto: Auto): GenerationSpec<T>

Uses Fiktion's automatic generation for this rule target.

Uses Fiktion's automatic generation for each element of this collection rule target.

@JvmName(name = "generatesAutoMap")
infix inline fun <Key, Value, MapType : Map<Key, Value>> RuleTarget<MapType>.generates(auto: Auto): MapGenerationSpec<Key, Value, MapType>

Uses Fiktion's automatic generation for each key and value of this map rule target.

Link copied to clipboard
infix inline fun <T> RuleNameTarget.generatesBy(noinline generator: Generator<T>): GenerationSpec<T>

Generates values for this name target and infers the target value type from generator.

infix fun <T> RuleTarget<T>.generatesBy(generator: Generator<T>): GenerationSpec<T>

Generates values for this rule target by invoking generator.

Generates values for this type-family target by invoking generator.

Link copied to clipboard

Generates each element for this collection rule target by invoking generator.

infix inline fun <Key, Value, MapType : Map<Key, Value>> RuleTarget<MapType>.generatesEach(noinline generator: Generator<Pair<Key, Value>>): MapEntrySpec<Key, Value, MapType>

Generates each entry for this map rule target by invoking generator.

Link copied to clipboard
@JvmName(name = "generatesByteIn")
infix fun RuleTarget<Byte>.generatesIn(range: IntRange): GenerationSpec<Byte>

Generates byte values within range.

Generates character values within range.

@JvmName(name = "generatesDoubleIn")
infix fun RuleTarget<Double>.generatesIn(range: ClosedFloatingPointRange<Double>): GenerationSpec<Double>

Generates double values within range.

@JvmName(name = "generatesFloatIn")
infix fun RuleTarget<Float>.generatesIn(range: ClosedFloatingPointRange<Float>): GenerationSpec<Float>

Generates float values within range.

Generates integer values within range.

Generates long values within range.

@JvmName(name = "generatesShortIn")
infix fun RuleTarget<Short>.generatesIn(range: IntRange): GenerationSpec<Short>

Generates short values within range.

@JvmName(name = "generatesUByteIn")
infix fun RuleTarget<UByte>.generatesIn(range: UIntRange): GenerationSpec<UByte>

Generates unsigned byte values within range.

Generates unsigned integer values within range.

Generates unsigned long values within range.

@JvmName(name = "generatesUShortIn")
infix fun RuleTarget<UShort>.generatesIn(range: UIntRange): GenerationSpec<UShort>

Generates unsigned short values within range.

Link copied to clipboard
infix inline fun <Key, Value, MapType : Map<Key, Value>> RuleTarget<MapType>.generatesKeys(noinline generator: Generator<Key>): MapKeySpec<Key, Value, MapType>
fun <Key, Value, MapType : Map<Key, Value>> RuleTarget<MapType>.generatesKeys(generator: Generator<Key>, keyType: KType?, valueType: KType?): MapKeySpec<Key, Value, MapType>

Generates map keys for this rule target by invoking generator.

Link copied to clipboard

Generates one value from values.

Link copied to clipboard
infix inline fun <Key, Value, MapType : Map<Key, Value>> RuleTarget<MapType>.generatesValues(noinline generator: Generator<Value>): MapValueSpec<Key, Value, MapType>

Generates map values for this rule target by invoking generator.