I looked into kapt, kotlinpoet, AutoService, looked at many tutorials, but I can't get anything working unfortunately
m
Matteo Mirk
12/20/2019, 11:16 AM
you have to write something to begin with, be it the very field itself, annotations, models to generate code from, whatever. Maybe for this particular need you could just use structural inheritance, but you’ll have to manually write the shared fields and super constructor initialization anyway.
If you’re sure you need a set of fields to be copied like in a factory line, then your only choice to reduce boilerplate (already minimal in :kotlin:) is to write a compiler plugin because kapt can only generate new sources and not modify existing classes
➕ 1
s
StavFX
12/20/2019, 6:43 PM
I would agree that inheritance sounds like a simpler approach to have multiple classes have the same fields.
Writing an annotation processor is pretty advanced (I’m saying this only because you posted in #getting-started), so I’m not sure that’s the solution you would want to go for.