https://kotlinlang.org logo
Title
e

elect

09/23/2021, 11:43 AM
Writing a dsl, the getters aren't supposed to be used, so I'm writing this at the moment:
var maxGCPauseMillis: Int
            get() = error("invalid")
            set(value) ..
does anyone have a better solution?
r

Roukanken

09/23/2021, 12:26 PM
why a property? If you have DLS of something that is not supposed to be read, I would expect it to look it like this from the user side:
myDsl {
    maxMillis(20)
}
1
e

elect

09/23/2021, 3:17 PM
because I like it more, I find it more readable
j

Joost Klitsie

09/24/2021, 5:48 AM
What is the harm in reading the value?
e

elect

09/24/2021, 6:24 AM
no harm, but it's not supposed to be read
seems like not really possible
especially since you cannot make the getter private
e

elect

09/24/2021, 7:09 AM
nice idea I found on the youtrack link reported there
var x: Double
        @Deprecated(message = "Write only property", level = DeprecationLevel.HIDDEN)
        get() = error()
        set(value) { source.x = value }
thanks @Joost Klitsie!