How can I get generate map init code with KotlinPoet?

520 views Asked by At

I am new one about KotlinPoet. Actaully, I want to generate code lines like the bellow with KAPT. There is not proper sample to generated init 'map' data. Is there anyone help me?

===> like this

package com.example.kotlintest

import kotlin.Pair
import kotlin.String

class InitMapData {
    val activityMap = mapOf<String, Pair<String,String>>(
        "aa" to  Pair("bb","cc"),
        "dd" to  Pair("ee","ff")
    )
  
}
1

There are 1 answers

1
West_JR On

Use .paramterizedBy off the PropertySpec.builder

it's in the docs under the "%T" for types section.