Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.navercorp.fixturemonkey.kotlin.KPropertyExtensions.kt Maven / Gradle / Ivy
Go to download
The easiest way to generate controllable arbitrary test objects
@file:Suppress("unused", "UNUSED_PARAMETER")
package com.navercorp.fixturemonkey.kotlin
import com.navercorp.fixturemonkey.ArbitraryBuilder
import com.navercorp.fixturemonkey.Constants
import java.util.function.Predicate
import java.util.function.Supplier
import kotlin.reflect.KProperty1
fun ArbitraryBuilder.set(property: KProperty1, value: Any?): ArbitraryBuilder =
this.set(propertyExpressionGenerator(property), value)
fun ArbitraryBuilder.set(property: KProperty1, value: Any?, limit: Long): ArbitraryBuilder =
this.set(propertyExpressionGenerator(property), value, limit.toInt())
fun ArbitraryBuilder.setNull(property: KProperty1): ArbitraryBuilder =
this.setNull(propertyExpressionGenerator(property))
fun ArbitraryBuilder.setNotNull(property: KProperty1): ArbitraryBuilder =
this.setNotNull(propertyExpressionGenerator(property))
fun ArbitraryBuilder.setPostCondition(
property: KProperty1,
clazz: Class,
filter: Predicate
): ArbitraryBuilder =
this.setPostCondition(
propertyExpressionGenerator(property),
clazz,
filter
)
fun ArbitraryBuilder.setPostCondition(
property: KProperty1,
clazz: Class,
filter: Predicate,
limit: Long
): ArbitraryBuilder =
this.setPostCondition(
propertyExpressionGenerator(property),
clazz,
filter,
limit.toInt()
)
fun ArbitraryBuilder.size(
property: KProperty1,
size: Int
): ArbitraryBuilder = this.size(propertyExpressionGenerator(property), size)
fun ArbitraryBuilder.size(
property: KProperty1,
min: Int,
max: Int
): ArbitraryBuilder = this.size(propertyExpressionGenerator(property), min, max)
fun ArbitraryBuilder.minSize(
property: KProperty1,
min: Int
): ArbitraryBuilder = this.minSize(propertyExpressionGenerator(property), min)
fun ArbitraryBuilder.maxSize(
property: KProperty1,
max: Int
): ArbitraryBuilder = this.maxSize(propertyExpressionGenerator(property), max)
fun ArbitraryBuilder.setLazy(
property: KProperty1,
supplier: Supplier
): ArbitraryBuilder = this.setLazy(propertyExpressionGenerator(property), supplier)
fun ArbitraryBuilder.setLazy(
property: KProperty1,
supplier: Supplier,
limit: Long
): ArbitraryBuilder = this.setLazy(propertyExpressionGenerator(property), supplier, limit.toInt())
// Exp
fun ArbitraryBuilder.setExp(property: KProperty1, value: Any?): ArbitraryBuilder =
this.set(propertyExpressionGenerator(property), value)
fun ArbitraryBuilder.setExp(property: KProperty1, value: Any?, limit: Long): ArbitraryBuilder =
this.set(propertyExpressionGenerator(property), value, limit.toInt())
fun ArbitraryBuilder.setNullExp(property: KProperty1): ArbitraryBuilder =
this.setNull(propertyExpressionGenerator(property))
fun ArbitraryBuilder.setNotNullExp(property: KProperty1): ArbitraryBuilder =
this.setNotNull(propertyExpressionGenerator(property))
fun ArbitraryBuilder.setPostConditionExp(
property: KProperty1,
clazz: Class,
filter: Predicate,
limit: Long
): ArbitraryBuilder =
this.setPostCondition(
propertyExpressionGenerator(property),
clazz,
filter,
limit.toInt()
)
fun ArbitraryBuilder.sizeExp(
property: KProperty1,
size: Int
): ArbitraryBuilder = this.size(propertyExpressionGenerator(property), size)
fun ArbitraryBuilder.sizeExp(
property: KProperty1,
min: Int,
max: Int
): ArbitraryBuilder = this.size(propertyExpressionGenerator(property), min, max)
fun ArbitraryBuilder.minSizeExp(
property: KProperty1,
min: Int
): ArbitraryBuilder = this.minSize(propertyExpressionGenerator(property), min)
fun ArbitraryBuilder.maxSizeExp(
property: KProperty1,
max: Int
): ArbitraryBuilder = this.maxSize(propertyExpressionGenerator(property), max)
fun ArbitraryBuilder.setLazyExp(
property: KProperty1,
supplier: Supplier
): ArbitraryBuilder = this.setLazy(propertyExpressionGenerator(property), supplier)
fun ArbitraryBuilder.setLazyExp(
property: KProperty1,
supplier: Supplier,
limit: Long
): ArbitraryBuilder = this.setLazy(propertyExpressionGenerator(property), supplier, limit.toInt())
// root
@JvmName("setRoot")
fun ArbitraryBuilder.set(property: KProperty1>, value: Any?): ArbitraryBuilder =
this.set("$", value)
@JvmName("setNullRoot")
fun ArbitraryBuilder.setNull(property: KProperty1>): ArbitraryBuilder =
this.setNull("$")
@JvmName("setNotNullRoot")
fun ArbitraryBuilder.setNotNull(property: KProperty1>): ArbitraryBuilder =
this.setNotNull("$")
inline fun ArbitraryBuilder.setPostCondition(
property: KProperty1>,
filter: Predicate
): ArbitraryBuilder =
this.setPostCondition(
"$",
T::class.java,
filter
)
inline fun ArbitraryBuilder.setPostCondition(
property: KProperty1>,
filter: Predicate,
limit: Long
): ArbitraryBuilder =
this.setPostCondition(
"$",
T::class.java,
filter,
limit.toInt()
)
@JvmName("sizeRoot")
fun ArbitraryBuilder.size(
property: KProperty1>,
size: Int
): ArbitraryBuilder = this.size("$", size)
@JvmName("sizeRoot")
fun ArbitraryBuilder.size(
property: KProperty1>,
min: Int,
max: Int
): ArbitraryBuilder = this.size("$", min, max)
@JvmName("minSizeRoot")
fun ArbitraryBuilder.minSize(
property: KProperty1>,
min: Int
): ArbitraryBuilder = this.minSize("$", min)
@JvmName("maxSizeRoot")
fun ArbitraryBuilder.maxSize(
property: KProperty1>,
min: Int
): ArbitraryBuilder = this.maxSize("$", min)
@JvmName("setLazyRoot")
fun ArbitraryBuilder.setLazy(
property: KProperty1>,
supplier: Supplier
): ArbitraryBuilder = this.setLazy("$", supplier)
@JvmName("setLazyRoot")
fun ArbitraryBuilder.setLazy(
property: KProperty1>,
supplier: Supplier,
limit: Long
): ArbitraryBuilder = this.setLazy("$", supplier, limit.toInt())
// rootExp
@JvmName("setRootExp")
fun ArbitraryBuilder.setExp(
property: KProperty1>,
value: Any?,
limit: Long = Constants.MAX_MANIPULATION_COUNT.toLong()
): ArbitraryBuilder =
this.set("$", value, limit.toInt())
@JvmName("setNullRootExp")
fun ArbitraryBuilder.setNullExp(property: KProperty1>): ArbitraryBuilder =
this.setNull("$")
@JvmName("setNotNullRootExp")
fun ArbitraryBuilder.setNotNullExp(property: KProperty1>): ArbitraryBuilder =
this.setNotNull("$")
inline fun ArbitraryBuilder.setPostConditionExp(
property: KProperty1>,
filter: Predicate
): ArbitraryBuilder =
this.setPostCondition(
"$",
T::class.java,
filter
)
@JvmName("sizeRootExp")
fun ArbitraryBuilder.sizeExp(
property: KProperty1>,
size: Int
): ArbitraryBuilder =
this.size("$", size)
@JvmName("sizeRootExp")
fun ArbitraryBuilder.sizeExp(
property: KProperty1>,
min: Int,
max: Int
): ArbitraryBuilder = this.size("$", min, max)
inline fun ArbitraryBuilder.setPostConditionExp(
property: KProperty1>,
filter: Predicate,
limit: Long = Constants.MAX_MANIPULATION_COUNT.toLong()
): ArbitraryBuilder =
this.setPostCondition(
"$",
T::class.java,
filter,
limit.toInt()
)
@JvmName("minSizeRootExp")
fun ArbitraryBuilder.minSizeExp(
property: KProperty1>,
min: Int
): ArbitraryBuilder = this.minSize("$", min)
@JvmName("maxSizeRootExp")
fun ArbitraryBuilder.maxSizeExp(
property: KProperty1>,
max: Int
): ArbitraryBuilder = this.maxSize("$", max)
@JvmName("setLazyRootExp")
fun ArbitraryBuilder.setLazyExp(
property: KProperty1>,
supplier: Supplier,
limit: Long = Constants.MAX_MANIPULATION_COUNT.toLong()
): ArbitraryBuilder = this.setLazy("$", supplier, limit.toInt())