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

e.ultra.mutator.0.77.0.source-code.DataClassMutator.kt Maven / Gradle / Ivy

package de.peekandpoke.ultra.mutator

import kotlin.reflect.KProperty0
import kotlin.reflect.jvm.javaField

open class DataClassMutator(input: T, onModify: OnModify) : MutatorBase(input, onModify) {

    fun  modify(property: KProperty0, old: X, new: X) {

        val field = property.javaField

        if (field != null) {

            field.isAccessible = true

            // We only trigger the cloning, when the value has changed
            if (old.isNotSameAs(new)) {
                field.set(getMutableResult(), new)
            }
        }
    }

    override fun copy(input: T): T = Cloner.cloneDataClass(input)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy