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

commonMain.org.hisp.dhis.rules.engine.RuleVariableValue.kt Maven / Gradle / Ivy

package org.hisp.dhis.rules.engine

import org.hisp.dhis.lib.expression.spi.ValueType
import org.hisp.dhis.lib.expression.spi.VariableValue
import org.hisp.dhis.rules.models.RuleValueType

data class RuleVariableValue(
    val type: RuleValueType,
    val value: String? = null,
    val candidates: List = listOf(),
    val eventDate: String? = null
) {
    fun toVariableValue(): VariableValue {
        return VariableValue(valueType(), value, candidates, eventDate)
    }

    private fun valueType(): ValueType {
        return when (type) {
            RuleValueType.DATE -> ValueType.DATE
            RuleValueType.NUMERIC -> ValueType.NUMBER
            RuleValueType.BOOLEAN -> ValueType.BOOLEAN
            else -> ValueType.STRING
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy