I know there's some work being done on reflection APIs, so perhaps this is premature, but I figured I'd toss out an issue and hopefully the reflection API will deal with it.
I love the data classes, and like to be able to declare a class as follows:
class SomeData(val id: String, val count: Int, val description: String)
I'd love to use these kinds of classes with reflection. For example, let's say I wanted to parse some JSON data into that data object:
{ "id": "abcdef", "count": 24, "description":"This is something"}
The problem is that I don't see how it can be done. In java, parameter names are not available via reflection. Now, I can get the names because under the hood, this class generates getters for id, count, and description. However, I can't tell what order they are in the constructor, and because they are immutable, there are no setters.
My current workaround is to use vars and a no-op constructor:
class SomeData { var id: String? = null var count: Int? = null var description: String? = null }
This then generates setters for all of the values. Unfortunately, this is a little bit more clutter, plus, it renders properties that would normally be immutable (ie. id) as mutable, and thus, doesn't properly communicate what the object is all about.
I could also add annotations to all of the parameters, but that creates a ton more extra code that just repeats things that are already available.
My first thought would be to make parameter names available via a reflection API, or at least include an annotation that makes those available. There may be better ways.
I think the data classes have incredible usefulness (OR mapping obviously), but the reflection API will need to provide as much information as possible for them to be useful.