[K/N][test] Fix annotation model generator for use with arrays
Generator should write arrays as java array with values, not its class
This commit is contained in:
committed by
Space Team
parent
1a9e553013
commit
487a441efc
+8
@@ -17,6 +17,7 @@ class AnnotationModel(
|
||||
val argumentsString = arguments.joinToString(separator = ", ") { argument ->
|
||||
val valueString = when (val value = argument.value) {
|
||||
is Enum<*> -> "${value.javaClass.simpleName}.${value.name}"
|
||||
is Array<*> -> value.toJavaString()
|
||||
is Class<*> -> "${value.simpleName}.class"
|
||||
else -> "\"$value\""
|
||||
}
|
||||
@@ -25,6 +26,13 @@ class AnnotationModel(
|
||||
p.print("@${annotation.simpleName}($argumentsString)")
|
||||
}
|
||||
|
||||
private fun Array<*>.toJavaString(): String =
|
||||
buildString {
|
||||
append("{ ")
|
||||
append(this@toJavaString.joinToString(separator = ", ") { "\"$it\"" })
|
||||
append(" }")
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
fun imports(): List<Class<*>> {
|
||||
return buildList {
|
||||
|
||||
Reference in New Issue
Block a user