Skip to content

Conversation

evgenysalnikov
Copy link

No description provided.


override var fullName: String by Delegates.vetoable(pi.fullName) { property, oldValue, newValue ->
pi.fullName = newValue
if (pi.fullName != newValue) return@vetoable false
Copy link
Author

@evgenysalnikov evgenysalnikov Sep 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут можно использовать рефлексию и сделать метод вроде

private fun changeField(property: KProperty<*>, oldValue: String, newValue: String) : Boolean {
        if (property is KMutableProperty1<*, *>) {
            val mutableKProperty = property as KMutableProperty1<ProfileImplementation, String>
            mutableKProperty.set(pi, newValue)

            val kProperty = property as KProperty1<ProfileImplementation, *>
            if (kProperty.get(pi) != newValue) return false
            log.add("Changing `${property.name}` from '$oldValue' to '${newValue}'")
            return true
        } else return false
    }

но тут, кажется, перебор

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant