寻找正确的 kotlinpoet 语法来为 IntArrays 和 Array<String> 值初始化 PropertySpec.Builder

Looking for correct kotlinpoet syntax to initialize a PropertySpec.Builder for IntArrays and Array<String> values

没有看到将数组类型初始化为项目中现有类型的值的正确语法,原始类型工作正常并且程序员定义 classes

Target(
    AnnotationTarget.FIELD,
    AnnotationTarget.PROPERTY_GETTER,
    AnnotationTarget.VALUE_PARAMETER,
    AnnotationTarget.PROPERTY)
    @Retention(AnnotationRetention.SOURCE)

注释class ConfigurableIntArray( 验证键:字符串, 验证文本:字符串, 值描述:字符串, val 初始值:IntArray )

Class BlockAnnotationTester2(@field:ConfigurableIntArray(
    key = UIComponentSettings.MAXIMUM_LENGTH_KEY,
    text = UIComponentSettings.MAXIMUM_LENGTH_TEXT,
    description = UIComponentSettings.MAXIMUM_LENGTH_DESCRIPTION,
    initialValue = [2]) 
val unusedIntArray: IntArray = intArrayOf(1, 2, 3, 4),

 for (data in memberDataIntArray)...`
addProperty( 
                  PropertySpec.builder(TestAnnotationProcessor.INITIAL_VALUE, IntArray::class) 

                        .initializer("intArrayOf(${data.annotation.initialValue.asList()})")
                        .build()
                ) 
   object Member_BlockAnnotationTester2UnusedIntArray {

    const val KEY: String = 
    "configurable_block_detail_ui_component_maximum_length"

    const val TEXT: String = "Maximum length"

    var INITIAL_VALUE: IntArray = intArrayOf([2]) <-- issue 

const val DESCRIPTION: String = "Maximum length of the corresponding UI 
component"
}

只能让它初始化为纯文本文字或第一个值中的静态数据

猜测有更简单的方法,但这个方法有效

.initializer("%L", buildCodeBlock {
                                var lregex = 
    data.annotation.initialValue.asList().toString()
                                lregex = lregex.replace("["," ")
                                lregex = lregex.replace("]"," ")
                                add("intArrayOf($lregex)")
                            })