org.jetbrains.kotlinx.dataframe.plugin.impl.ExpectedArgumentDelegates.kt Maven / Gradle / Ivy
The newest version!
package org.jetbrains.kotlinx.dataframe.plugin.impl
import org.jetbrains.kotlinx.dataframe.plugin.impl.AbstractInterpreter.*
import org.jetbrains.kotlinx.dataframe.plugin.impl.api.TypeApproximation
import org.jetbrains.kotlinx.dataframe.plugin.impl.data.DataFrameCallableId
import kotlin.properties.PropertyDelegateProvider
import kotlin.properties.ReadOnlyProperty
typealias ExpectedArgumentProvider = PropertyDelegateProvider>
fun AbstractInterpreter.dataFrame(
name: ArgumentName? = null
): ExpectedArgumentProvider = arg(name, lens = Interpreter.Schema)
fun AbstractInterpreter.type(
name: ArgumentName? = null
): ExpectedArgumentProvider = arg(name, lens = Interpreter.ReturnType)
fun > AbstractInterpreter.enum(
name: ArgumentName? = null,
defaultValue: DefaultValue = Absent
): ExpectedArgumentProvider = argConvert(name = name, defaultValue = defaultValue) { it: DataFrameCallableId ->
val forName: Class<*> = Class.forName("${it.packageName}.${it.className}")
@Suppress("UNCHECKED_CAST")
java.lang.Enum.valueOf(forName as Class>, it.callableName) as E
}
internal fun AbstractInterpreter.dsl(
name: ArgumentName? = null
): ExpectedArgumentProvider<(Any, Map>) -> Unit> =
arg(name, lens = Interpreter.Dsl, defaultValue = Present(value = {_, _ -> }))
internal fun AbstractInterpreter.ignore(
name: ArgumentName? = null
): ExpectedArgumentProvider =
arg(name, lens = Interpreter.Id, defaultValue = Present(null))
© 2015 - 2024 Weber Informatics LLC | Privacy Policy