com.ancientlightstudios.quarkus.kotlin.openapi.emitter.deserialization.DefaultValueStatementEmitter.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.emitter.deserialization
import com.ancientlightstudios.quarkus.kotlin.openapi.emitter.CodeEmitter
import com.ancientlightstudios.quarkus.kotlin.openapi.emitter.EmitterContext
import com.ancientlightstudios.quarkus.kotlin.openapi.models.kotlin.InvocationExpression.Companion.invoke
import com.ancientlightstudios.quarkus.kotlin.openapi.models.kotlin.KotlinExpression
import com.ancientlightstudios.quarkus.kotlin.openapi.models.kotlin.MethodName.Companion.methodName
import com.ancientlightstudios.quarkus.kotlin.openapi.models.kotlin.MethodName.Companion.rawMethodName
import com.ancientlightstudios.quarkus.kotlin.openapi.models.kotlin.wrap
class DefaultValueStatementEmitter(
private val defaultValue: KotlinExpression?,
baseStatement: KotlinExpression
) : CodeEmitter {
var resultStatement = baseStatement
// if a default value is specified, generates an expression like this
//
//
// .default { }
override fun EmitterContext.emit() {
if (defaultValue != null) {
resultStatement = resultStatement.wrap().invoke("default".rawMethodName()) {
defaultValue.statement()
}
}
}
}