Renjith
Renjith

Reputation: 417

How to add a function definition available in a string to a class generated from kotlinpoet TypeSpec?

I am generating a class using kotlinpoet and one of the method to be generated is available to me as string (full function definition), how will I add that to a TypeSpec?

// if I have function definition like this
val funDefinition = "fun myFun(){}"

// I don't want to generate like following
TypeSpec.classBuilder("myClass").addFunction(FunSpec.builder("myFun").build())

// I could not see an option like following
TypeSpec.classBuilder("myClass").aMethodToAddFunctionFromString(funDefinition)

Is this possible with kotlinpoet or with some other library?

Upvotes: 0

Views: 76

Answers (0)

Related Questions