Question: How can one annotate properties in a Kot...
# android
f
Question: How can one annotate properties in a Kotlin interface and handle them with an Annotation processor? What for? I am developing an Annotation and code generation based library for Android shared preferences. The idea is to decorate properties in an interface and generate the code needed to store and retrieve those properties to and from the SharedPreferences. Simply decorating does not seem to work; the processor can't find any of the target properties. The current workaround is using functions instead of properties. Properties would be so much better and technically sound though. The project is the following in case you want to have a look: https://github.com/iFanie/ConfigurNation
l
@fanie You can do this with delegated properties. You can see the implementation of this library I made: https://github.com/LouisCAD/Splitties/tree/master/preferences
f
@louiscad thanks for the suggestion, but that is a very different approach. My concern is that I can't seem to access decorated abstract properties from the Annotation processor.
l
Yes it is, but it can work with interface abstraction, without hacking into annotation processors (which also have an impact on build time)
f
@louiscad still, I'm not looking for that though. I can't seem to get the processor to see the annotated abstract variables