I'm trying to generate code to declare a class with a @TypeParceler annotation.
I can create a ParameterizedTypeName with:
val myParcelerClass = ClassName("com.example", "MyParceler")
val genericTypeParcelerClass = ClassName("kotlinx.android.parcel", "TypeParceler")
val parameterizedTypeParcelerClass = genericTypeParcelerClass.plusParameter(MyType::class.asClassName()).plusParameter(myParcelerClass)
I'd like to add an annotation with parameterizedTypeParcelerClass
using TypeSpec.Builder.addAnnotation() but there isn't an override with a TypeName. Like this:
val myTargetClass = ClassName("com.example", "MyTarget")
val classBuilder = TypeSpec.classBuilder(myTargetClass)
.addAnnotation(parameterizedTypeParcelerClass)
The TypeParceler annotation class is not available to the KotlinPoet code because the Android extension library isn't included here.
Is there a way to do this that I'm missing?