First, let’s thank you for Kotlin that we find really great. Now our question :
Let’s say I have a class Person ( val firstName:String, val lastName:String, val optionalSomething: String? )
Using this class with all fields set to not-null is great, evertyhing is under strict null control… while the software doesn’t interact with outer environment
In some scenarios ( filtering user input for example, i/o, etc.) we want to use the same class, maybe with a higher order definition, but find a way to indicate that all fields are at some point nullable.
For example it could be something like Partial where we would end up with it being defined as ( val firstName:String?, val lastName:String?, val optionalSomething: String? )
We agree that we could create manually another class like PartialPerson, but in large domain-driven cases, code is automatically generated, and in our case we end up with 500+ such objects with an average of 20+ (sometimes 50+) fields for each.
So it’s impossible to create manually new classes and their adapters just to “nullify” fields. It would be a burden to make code generators generate partials and also would be complicated for developer.
Is there something we missed in language features or does somebody has an idea on how to do that ?
Thank you all