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

divkit.dsl.FixedCount.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.28.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

/**
 * Fixed number of repetitions.
 * 
 * Can be created using the method [fixedCount].
 * 
 * Required parameters: `value, type`.
 */
@Generated
class FixedCount internal constructor(
    @JsonIgnore
    val properties: Properties,
) : Count {
    @JsonAnyGetter
    internal fun getJsonProperties(): Map = properties.mergeWith(
        mapOf("type" to "fixed")
    )

    operator fun plus(additive: Properties): FixedCount = FixedCount(
        Properties(
            value = additive.value ?: properties.value,
        )
    )

    class Properties internal constructor(
        /**
         * Number of repetitions.
         */
        val value: Property?,
    ) {
        internal fun mergeWith(properties: Map): Map {
            val result = mutableMapOf()
            result.putAll(properties)
            result.tryPutProperty("value", value)
            return result
        }
    }
}

/**
 * @param value Number of repetitions.
 */
@Generated
fun DivScope.fixedCount(
    `use named arguments`: Guard = Guard.instance,
    value: Int? = null,
): FixedCount = FixedCount(
    FixedCount.Properties(
        value = valueOrNull(value),
    )
)

/**
 * @param value Number of repetitions.
 */
@Generated
fun DivScope.fixedCountProps(
    `use named arguments`: Guard = Guard.instance,
    value: Int? = null,
) = FixedCount.Properties(
    value = valueOrNull(value),
)

/**
 * @param value Number of repetitions.
 */
@Generated
fun TemplateScope.fixedCountRefs(
    `use named arguments`: Guard = Guard.instance,
    value: ReferenceProperty? = null,
) = FixedCount.Properties(
    value = value,
)

/**
 * @param value Number of repetitions.
 */
@Generated
fun FixedCount.override(
    `use named arguments`: Guard = Guard.instance,
    value: Int? = null,
): FixedCount = FixedCount(
    FixedCount.Properties(
        value = valueOrNull(value) ?: properties.value,
    )
)

/**
 * @param value Number of repetitions.
 */
@Generated
fun FixedCount.defer(
    `use named arguments`: Guard = Guard.instance,
    value: ReferenceProperty? = null,
): FixedCount = FixedCount(
    FixedCount.Properties(
        value = value ?: properties.value,
    )
)

/**
 * @param value Number of repetitions.
 */
@Generated
fun FixedCount.evaluate(
    `use named arguments`: Guard = Guard.instance,
    value: ExpressionProperty? = null,
): FixedCount = FixedCount(
    FixedCount.Properties(
        value = value ?: properties.value,
    )
)

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy