# announcements


01/05/2021, 7:21 PM
For a Spring Boot app we want to add some extra meta data to particular fields in the JSON response. Since this is a "cross cutting" concern in our project we want to make this as simple/concise as possible. We made a proof of concept with annotations. So we created 2 annotations and used reflection to generate the metadata based on the annotated fields. An example to use this is:
Copy code
data class Response(
    val id: Int,
    val label: LabelResponse
The idea that for the field
we generate some metadata and add this as extra fields in
. I wonder if there's a way to reach our goal without annotations and reflection. I read about making DSL's in Kotlin, but I couldn't directly find something for our situation. I'm happy to hear your thoughts.

Sasha Shpota

01/05/2021, 7:33 PM
I think you can try using delegated properties here. The properties would look like normal properties for the clients, but they will have additional functionality attached to them. I am not sure if it fits well for your particular usages, but you might want to check JetBrains/Exposed to see what you can do with them on a real project.
👍 2


01/05/2021, 8:37 PM
At a first glance it looks like it may fit my case, but I'm not sure. I will play around with it. Thnx Sasha


01/06/2021, 8:46 AM
with annotations but without reflection you could use a compile-time annotation processor • otherwise, AOP is still possible


01/06/2021, 1:10 PM
• Good point! That is our next step in our PoC, because we also want to add compile-time "validation". Didn't know we can drop reflection then as well. • Thx for that pointer, I will look a bit into AoP in Kotlin