Dave Leeds
09/15/2017, 9:10 PMpublic class Example {
private String value = "";
public String getValue() {
return value;
}
}
For mocking reasons, I need the getValue()
method to be open, but I want to keep any setter private. Here’s what I tried in Kotlin:
open class Example {
open var value: String = ""
private set
}
But, that won’t compile: Private setters are not allowed for open properties
Is there any way to achieve this without using backing fields?