All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ancientlightstudios.quarkus.kotlin.openapi.utils.CodeWriterExtension.kt Maven / Gradle / Ivy

There is a newer version: 0.4.14
Show newest version
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)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy