Runtime Metaclass for a Kotlin Data class

Hi,

This might already be possible, but have no idea on how to achieve it:

I have a bunch of Kotlin data class which I use for loading data from an ugly external source, then show it to the user to do some simple manipulations to ultimately save that data into the real Entities.

Right know I’m abusing the KeyValueCollection and KeyValueEntity for the UI part but reading the documentation it appears that CUBA does create some runtime metaclass for this things. So…

Is it possible to create a metaclass for a Kotlin data class (ie: define it at runtime?)

I know I could just use @Metaclass, but the main point here is to benefit from the concise syntax of data classes which is lost otherwise

Hi Marc,

It is possible, but not so easy. We did similar things for our EntityViews PoC project by registering interfaces as entities. I think something can be done for Kotlin data classes. We definitely consider this for the next version of the framework. I guess we’ll keep the community updated on forum, Twitter and Facebook.

2 Likes