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

divkit.dsl.ActionDictSetValue.kt Maven / Gradle / Ivy

Go to download

DivKit is an open source Server-Driven UI (SDUI) framework. SDUI is a an emerging technique that leverage the server to build the user interfaces of their mobile app.

There is a newer version: 30.19.0
Show newest version
@file:Suppress(
    "unused",
    "UNUSED_PARAMETER",
)

package divkit.dsl

import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonValue
import divkit.dsl.annotation.*
import divkit.dsl.core.*
import divkit.dsl.scope.*
import kotlin.Any
import kotlin.String
import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.Map

/**
 * Sets value in dictionary for the given key. Removes key if the value is not defined.
 * 
 * Can be created using the method [actionDictSetValue].
 * 
 * Required parameters: `variable_name, type, key`.
 */
@Generated
class ActionDictSetValue internal constructor(
    @JsonIgnore
    val properties: Properties,
) : ActionTyped {
    @JsonAnyGetter
    internal fun getJsonProperties(): Map = properties.mergeWith(
        mapOf("type" to "dict_set_value")
    )

    operator fun plus(additive: Properties): ActionDictSetValue = ActionDictSetValue(
        Properties(
            key = additive.key ?: properties.key,
            value = additive.value ?: properties.value,
            variableName = additive.variableName ?: properties.variableName,
        )
    )

    class Properties internal constructor(
        val key: Property?,
        val value: Property?,
        val variableName: Property?,
    ) {
        internal fun mergeWith(properties: Map): Map {
            val result = mutableMapOf()
            result.putAll(properties)
            result.tryPutProperty("key", key)
            result.tryPutProperty("value", value)
            result.tryPutProperty("variable_name", variableName)
            return result
        }
    }
}

@Generated
fun DivScope.actionDictSetValue(
    `use named arguments`: Guard = Guard.instance,
    key: String? = null,
    value: TypedValue? = null,
    variableName: String? = null,
): ActionDictSetValue = ActionDictSetValue(
    ActionDictSetValue.Properties(
        key = valueOrNull(key),
        value = valueOrNull(value),
        variableName = valueOrNull(variableName),
    )
)

@Generated
fun DivScope.actionDictSetValueProps(
    `use named arguments`: Guard = Guard.instance,
    key: String? = null,
    value: TypedValue? = null,
    variableName: String? = null,
) = ActionDictSetValue.Properties(
    key = valueOrNull(key),
    value = valueOrNull(value),
    variableName = valueOrNull(variableName),
)

@Generated
fun TemplateScope.actionDictSetValueRefs(
    `use named arguments`: Guard = Guard.instance,
    key: ReferenceProperty? = null,
    value: ReferenceProperty? = null,
    variableName: ReferenceProperty? = null,
) = ActionDictSetValue.Properties(
    key = key,
    value = value,
    variableName = variableName,
)

@Generated
fun ActionDictSetValue.override(
    `use named arguments`: Guard = Guard.instance,
    key: String? = null,
    value: TypedValue? = null,
    variableName: String? = null,
): ActionDictSetValue = ActionDictSetValue(
    ActionDictSetValue.Properties(
        key = valueOrNull(key) ?: properties.key,
        value = valueOrNull(value) ?: properties.value,
        variableName = valueOrNull(variableName) ?: properties.variableName,
    )
)

@Generated
fun ActionDictSetValue.defer(
    `use named arguments`: Guard = Guard.instance,
    key: ReferenceProperty? = null,
    value: ReferenceProperty? = null,
    variableName: ReferenceProperty? = null,
): ActionDictSetValue = ActionDictSetValue(
    ActionDictSetValue.Properties(
        key = key ?: properties.key,
        value = value ?: properties.value,
        variableName = variableName ?: properties.variableName,
    )
)

@Generated
fun ActionDictSetValue.evaluate(
    `use named arguments`: Guard = Guard.instance,
    key: ExpressionProperty? = null,
    variableName: ExpressionProperty? = null,
): ActionDictSetValue = ActionDictSetValue(
    ActionDictSetValue.Properties(
        key = key ?: properties.key,
        value = properties.value,
        variableName = variableName ?: properties.variableName,
    )
)

@Generated
fun ActionDictSetValue.asList() = listOf(this)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy