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

at.kopyk.poet.FunSpec.kt Maven / Gradle / Ivy

package at.kopyk.poet

import com.squareup.kotlinpoet.FunSpec
import com.squareup.kotlinpoet.ParameterSpec
import com.squareup.kotlinpoet.TypeName

public fun FunSpec.Builder.addReturn(expr: String, vararg args: Any?): FunSpec.Builder =
  addCode("return $expr", args)

public fun FunSpec.Builder.addParameter(name: String, type: TypeName, defaultValue: String? = null) {
  addParameter(
    ParameterSpec.builder(name = name, type = type).apply {
      if (defaultValue != null) defaultValue(defaultValue)
    }.build()
  )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy