
com.ancientlightstudios.quarkus.kotlin.openapi.models.kotlin.WhenExpression.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.models.kotlin
import com.ancientlightstudios.quarkus.kotlin.openapi.emitter.CodeWriter
class WhenExpression(private val expression: KotlinExpression?) : KotlinExpression, WhenOptionAware {
private val options = KotlinRenderableBlockContainer(false)
override fun addOption(option: WhenOption) {
options.addItem(option)
}
override fun ImportCollector.registerImports() {
expression?.let { registerFrom(it) }
registerFrom(options)
}
override fun render(writer: CodeWriter) = with(writer) {
write("when ")
if (expression != null) {
write("(")
expression.render(this)
write(") ")
}
block {
options.render(this)
}
}
companion object {
fun whenExpression(expression: KotlinExpression? = null, block: WhenExpression.() -> Unit) =
WhenExpression(expression).apply(block)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy