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

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

There is a newer version: 1.1.3
Show newest version
/*
 * Fixture Monkey
 *
 * Copyright (c) 2021-present NAVER Corp.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.navercorp.fixturemonkey.kotlin

import com.navercorp.fixturemonkey.ArbitraryBuilder
import com.navercorp.fixturemonkey.FixtureMonkey
import com.navercorp.fixturemonkey.FixtureMonkeyBuilder
import com.navercorp.fixturemonkey.api.container.DecomposedContainerValueFactory
import com.navercorp.fixturemonkey.api.generator.ContainerPropertyGenerator
import com.navercorp.fixturemonkey.api.generator.NullInjectGenerator
import com.navercorp.fixturemonkey.api.generator.ObjectPropertyGenerator
import com.navercorp.fixturemonkey.api.introspector.ArbitraryIntrospector
import com.navercorp.fixturemonkey.api.matcher.Matcher
import com.navercorp.fixturemonkey.api.property.PropertyGenerator
import com.navercorp.fixturemonkey.api.property.PropertyNameResolver
import kotlin.reflect.KClass

inline fun  FixtureMonkeyBuilder.pushAssignableTypePropertyGenerator(propertyGenerator: PropertyGenerator) =
    this.pushAssignableTypePropertyGenerator(
        T::class.java,
        propertyGenerator
    )

inline fun  FixtureMonkeyBuilder.pushExactTypePropertyGenerator(propertyGenerator: PropertyGenerator) =
    this.pushExactTypePropertyGenerator(
        T::class.java,
        propertyGenerator
    )

inline fun  FixtureMonkeyBuilder.pushAssignableTypeObjectPropertyGenerator(objectPropertyGenerator: ObjectPropertyGenerator) =
    this.pushAssignableTypeObjectPropertyGenerator(
        T::class.java,
        objectPropertyGenerator
    )

inline fun  FixtureMonkeyBuilder.pushExactTypeObjectPropertyGenerator(objectPropertyGenerator: ObjectPropertyGenerator) =
    this.pushExactTypeObjectPropertyGenerator(
        T::class.java,
        objectPropertyGenerator
    )

inline fun  FixtureMonkeyBuilder.pushAssignableTypeContainerPropertyGenerator(
    containerPropertyGenerator: ContainerPropertyGenerator
) = this.pushAssignableTypeContainerPropertyGenerator(
    T::class.java,
    containerPropertyGenerator
)

inline fun  FixtureMonkeyBuilder.pushExactTypeContainerPropertyGenerator(containerPropertyGenerator: ContainerPropertyGenerator) =
    this.pushExactTypeContainerPropertyGenerator(
        T::class.java,
        containerPropertyGenerator
    )

inline fun  FixtureMonkeyBuilder.pushAssignableTypePropertyNameResolver(propertyNameResolver: PropertyNameResolver) =
    this.pushAssignableTypePropertyNameResolver(
        T::class.java,
        propertyNameResolver
    )

inline fun  FixtureMonkeyBuilder.pushExactTypePropertyNameResolver(propertyNameResolver: PropertyNameResolver) =
    this.pushExactTypePropertyNameResolver(
        T::class.java,
        propertyNameResolver
    )

inline fun  FixtureMonkeyBuilder.pushExactTypeNullInjectGenerator(nullInjectGenerator: NullInjectGenerator) =
    this.pushExactTypeNullInjectGenerator(
        T::class.java,
        nullInjectGenerator
    )

inline fun  FixtureMonkeyBuilder.pushAssignableTypeNullInjectGenerator(nullInjectGenerator: NullInjectGenerator) =
    this.pushAssignableTypeNullInjectGenerator(
        T::class.java,
        nullInjectGenerator
    )

inline fun  FixtureMonkeyBuilder.pushAssignableTypeArbitraryIntrospector(arbitraryIntrospector: ArbitraryIntrospector) =
    this.pushAssignableTypeArbitraryIntrospector(
        T::class.java,
        arbitraryIntrospector
    )

inline fun  FixtureMonkeyBuilder.pushExactTypeArbitraryIntrospector(arbitraryIntrospector: ArbitraryIntrospector) =
    this.pushExactTypeArbitraryIntrospector(
        T::class.java,
        arbitraryIntrospector
    )

inline fun  FixtureMonkeyBuilder.addExceptGenerateClass(): FixtureMonkeyBuilder =
    this.addExceptGenerateClass(T::class.java)

fun FixtureMonkeyBuilder.addExceptGenerateClasses(
    vararg kClasses: KClass<*>
): FixtureMonkeyBuilder =
    this.addExceptGenerateClasses(*(kClasses.map { it.java }.toTypedArray()))

inline fun  FixtureMonkeyBuilder.register(
    noinline arbitraryBuilderGenerator: (fixtureMonkey: FixtureMonkey) -> ArbitraryBuilder
): FixtureMonkeyBuilder = this.register(T::class.java, arbitraryBuilderGenerator)

inline fun  FixtureMonkeyBuilder.registerExactType(
    noinline arbitraryBuilderGenerator: (fixtureMonkey: FixtureMonkey) -> ArbitraryBuilder
): FixtureMonkeyBuilder = this.registerExactType(T::class.java, arbitraryBuilderGenerator)

inline fun  FixtureMonkeyBuilder.registerAssignableType(
    noinline arbitraryBuilderGenerator: (fixtureMonkey: FixtureMonkey) -> ArbitraryBuilder
): FixtureMonkeyBuilder = this.registerAssignableType(T::class.java, arbitraryBuilderGenerator)

fun FixtureMonkeyBuilder.registerGroup(
    vararg kClasses: KClass<*>
): FixtureMonkeyBuilder =
    this.registerGroup(*(kClasses.map { it.java }.toTypedArray()))

inline fun  FixtureMonkeyBuilder.addContainerType(
    containerObjectPropertyGenerator: ContainerPropertyGenerator,
    containerArbitraryIntrospector: ArbitraryIntrospector,
    decomposedContainerValueFactory: DecomposedContainerValueFactory
): FixtureMonkeyBuilder = this.addContainerType(
    T::class.java,
    containerObjectPropertyGenerator,
    containerArbitraryIntrospector,
    decomposedContainerValueFactory
)

inline fun  FixtureMonkeyBuilder.interfaceImplements(
    matcher: Matcher,
    implementations: List>
): FixtureMonkeyBuilder =
    this.interfaceImplements(matcher, implementations.map { it.java })

inline fun  FixtureMonkeyBuilder.interfaceImplements(
    vararg implementations: KClass
): FixtureMonkeyBuilder = this.interfaceImplements(T::class.java, implementations.map { it.java })

inline fun  FixtureMonkeyBuilder.interfaceImplements(
    implementations: List>
): FixtureMonkeyBuilder = this.interfaceImplements(T::class.java, implementations.map { it.java })




© 2015 - 2024 Weber Informatics LLC | Privacy Policy