Is there a solution to provide sensible default values for constructor parameters automatically?
For example in case of the following class:
@WithDefaults
class A(p1 : Int, p2 : String, p3 : String?, p4: List<Long>, p5 : SomeClass) {
}
I would like to have an empty constructor added automatically:
@WithDefaults
class A(p1 : Int, p2 : String, p3 : String?, p4 : List<Long>) {
constructor() : this(0, "", null, emptyList(), SomeClass())
}
The whole point would be not to write out the default values.
I think is not equivalent to the no-args
compiler plugin as:
- it have to actually set values, paying attention to nullability and making class instances
- should be multiplatform
- should be accessible from normal Kotlin code
I’ll probably write this if there is not one out there already, hence asking.