How to get KClass<List<String>> type from List<String> in kotlin

444 views Asked by At

I'm having problem with Kotlin poet PropertySpec object. Because i can't provide List<String> to the PropertySpec builder.

Help please.

PropertySpec.builder("services", List<String>::class.asTypeName()).build()
1

There are 1 answers

0
AmrDeveloper On

To add generics types info you need to use parameterizedBy for example

val stringList = ClassName("kotlin.collections", "List").parameterizedBy(String::class.asTypeName())