com.ancientlightstudios.quarkus.kotlin.openapi.utils.CodeWriterExtension.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-kotlin-openapi-maven-plugin Show documentation
Show all versions of quarkus-kotlin-openapi-maven-plugin Show documentation
A Maven plugin to use the OpenAPI generator.
package com.ancientlightstudios.quarkus.kotlin.openapi.utils
import com.ancientlightstudios.quarkus.kotlin.openapi.emitter.CodeWriter
fun CodeWriter.renderWithWrap(
parameters: List,
maxSizeForSingleLine: Int = 1,
delimiter: String = ", ",
block: CodeWriter.(T) -> Unit
) {
// block to render the parameters. but will be called later
val parameterBlock: CodeWriter.(Boolean) -> Unit = { newLine ->
parameters.forEachWithStats { status, it ->
block(it)
if (!status.last) {
write(delimiter, newLineAfter = newLine)
}
}
}
if (parameters.size > maxSizeForSingleLine) {
indent(newLineBefore = true, newLineAfter = true) { parameterBlock(true) }
} else {
parameterBlock(false)
}
}