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

com.ancientlightstudios.quarkus.kotlin.openapi.emitter.deserialization.DefaultValueStatementEmitter.kt Maven / Gradle / Ivy

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

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy