All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.navercorp.fixturemonkey.kotlin.KFunctionExtensions.kt Maven / Gradle / Ivy

There is a newer version: 1.1.3
Show newest version
@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.KFunction1

fun  ArbitraryBuilder.setExpGetter(property: KFunction1, value: Any?): ArbitraryBuilder =
    this.set(propertyExpressionGenerator(property), value)

fun  ArbitraryBuilder.setExpGetter(property: KFunction1, value: Any?, limit: Long): ArbitraryBuilder =
    this.set(
        propertyExpressionGenerator(property),
        value,
        limit.toInt()
    )

fun  ArbitraryBuilder.setNullExpGetter(property: KFunction1): ArbitraryBuilder =
    this.setNull(propertyExpressionGenerator(property))

fun  ArbitraryBuilder.setNotNullExpGetter(property: KFunction1): ArbitraryBuilder =
    this.setNotNull(propertyExpressionGenerator(property))

fun  ArbitraryBuilder.setPostConditionExpGetter(
    property: KFunction1,
    clazz: Class,
    filter: Predicate,
    limit: Long
): ArbitraryBuilder =
    this.setPostCondition(
        propertyExpressionGenerator(property),
        clazz,
        filter,
        limit.toInt()
    )

fun  ArbitraryBuilder.setPostConditionExpGetter(
    property: KFunction1,
    clazz: Class,
    filter: Predicate
): ArbitraryBuilder =
    this.setPostCondition(
        propertyExpressionGenerator(property),
        clazz,
        filter
    )

fun  ArbitraryBuilder.sizeExpGetter(
    property: KFunction1,
    size: Int
): ArbitraryBuilder =
    this.size(propertyExpressionGenerator(property), size)

fun  ArbitraryBuilder.sizeExpGetter(
    property: KFunction1,
    min: Int,
    max: Int
): ArbitraryBuilder =
    this.size(propertyExpressionGenerator(property), min, max)

fun  ArbitraryBuilder.minSizeExpGetter(
    property: KFunction1,
    min: Int
): ArbitraryBuilder =
    this.minSize(propertyExpressionGenerator(property), min)

fun  ArbitraryBuilder.maxSizeExpGetter(
    property: KFunction1,
    max: Int
): ArbitraryBuilder =
    this.maxSize(propertyExpressionGenerator(property), max)

fun  ArbitraryBuilder.setLazyExpGetter(
    property: KFunction1,
    supplier: Supplier
): ArbitraryBuilder =
    this.setLazy(propertyExpressionGenerator(property), supplier)

fun  ArbitraryBuilder.setLazyExpGetter(
    property: KFunction1,
    supplier: Supplier,
    limit: Long
): ArbitraryBuilder =
    this.setLazy(propertyExpressionGenerator(property), supplier, limit.toInt())

// root
@JvmName("setRootExpGetter")
fun  ArbitraryBuilder.setExpGetter(
    property: KFunction1>,
    value: Any?,
    limit: Long = Constants.MAX_MANIPULATION_COUNT.toLong()
): ArbitraryBuilder =
    this.set("$", value, limit.toInt())

@JvmName("setNullRootExpGetter")
fun  ArbitraryBuilder.setNullExpGetter(property: KFunction1>): ArbitraryBuilder =
    this.setNull("$")

@JvmName("setNotNullRootExpGetter")
fun  ArbitraryBuilder.setNotNullExpGetter(property: KFunction1>): ArbitraryBuilder =
    this.setNotNull("$")

@JvmName("sizeRootExpGetter")
fun  ArbitraryBuilder.sizeExpGetter(
    property: KFunction1>,
    size: Int
): ArbitraryBuilder =
    this.size("$", size)

@JvmName("sizeRootExpGetter")
fun  ArbitraryBuilder.sizeExpGetter(
    property: KFunction1>,
    min: Int,
    max: Int
): ArbitraryBuilder =
    this.size("$", min, max)

@JvmName("minSizeRootExpGetter")
fun  ArbitraryBuilder.minSizeExpGetter(
    property: KFunction1>,
    min: Int
): ArbitraryBuilder = this.minSize("$", min)

@JvmName("maxSizeRootExpGetter")
fun  ArbitraryBuilder.maxSizeExpGetter(
    property: KFunction1>,
    max: Int
): ArbitraryBuilder = this.maxSize("$", max)

inline fun  ArbitraryBuilder.setPostConditionExpGetter(
    property: KFunction1>,
    filter: Predicate,
    limit: Long = Constants.MAX_MANIPULATION_COUNT.toLong()
): ArbitraryBuilder =
    this.setPostCondition(
        "$",
        T::class.java,
        filter,
        limit.toInt()
    )

@JvmName("setLazyRootExpGetter")
fun  ArbitraryBuilder.setLazyExpGetter(
    property: KFunction1>,
    supplier: Supplier,
    limit: Long = Constants.MAX_MANIPULATION_COUNT.toLong()
): ArbitraryBuilder = this.setLazy("$", supplier, limit.toInt())