All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
divkit.dsl.Extension.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.
@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
/**
* Extension that affects an element.
*
* Can be created using the method [extension].
*
* Required parameters: `id`.
*/
@Generated
class Extension internal constructor(
@JsonIgnore
val properties: Properties,
) {
@JsonAnyGetter
internal fun getJsonProperties(): Map = properties.mergeWith(emptyMap())
operator fun plus(additive: Properties): Extension = Extension(
Properties(
id = additive.id ?: properties.id,
params = additive.params ?: properties.params,
)
)
class Properties internal constructor(
/**
* Extension ID.
*/
val id: Property?,
/**
* Additional extension parameters.
*/
val params: Property>?,
) {
internal fun mergeWith(properties: Map): Map {
val result = mutableMapOf()
result.putAll(properties)
result.tryPutProperty("id", id)
result.tryPutProperty("params", params)
return result
}
}
}
/**
* @param id Extension ID.
* @param params Additional extension parameters.
*/
@Generated
fun DivScope.extension(
`use named arguments`: Guard = Guard.instance,
id: String? = null,
params: Map? = null,
): Extension = Extension(
Extension.Properties(
id = valueOrNull(id),
params = valueOrNull(params),
)
)
/**
* @param id Extension ID.
* @param params Additional extension parameters.
*/
@Generated
fun DivScope.extensionProps(
`use named arguments`: Guard = Guard.instance,
id: String? = null,
params: Map? = null,
) = Extension.Properties(
id = valueOrNull(id),
params = valueOrNull(params),
)
/**
* @param id Extension ID.
* @param params Additional extension parameters.
*/
@Generated
fun TemplateScope.extensionRefs(
`use named arguments`: Guard = Guard.instance,
id: ReferenceProperty? = null,
params: ReferenceProperty>? = null,
) = Extension.Properties(
id = id,
params = params,
)
/**
* @param id Extension ID.
* @param params Additional extension parameters.
*/
@Generated
fun Extension.override(
`use named arguments`: Guard = Guard.instance,
id: String? = null,
params: Map? = null,
): Extension = Extension(
Extension.Properties(
id = valueOrNull(id) ?: properties.id,
params = valueOrNull(params) ?: properties.params,
)
)
/**
* @param id Extension ID.
* @param params Additional extension parameters.
*/
@Generated
fun Extension.defer(
`use named arguments`: Guard = Guard.instance,
id: ReferenceProperty? = null,
params: ReferenceProperty>? = null,
): Extension = Extension(
Extension.Properties(
id = id ?: properties.id,
params = params ?: properties.params,
)
)
@Generated
fun Extension.asList() = listOf(this)