divkit.dsl.CollectionItemBuilder.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-json-builder Show documentation
Show all versions of kotlin-json-builder Show documentation
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
/**
* Can be created using the method [collectionItemBuilder].
*
* Required parameters: `prototypes, data`.
*/
@Generated
class CollectionItemBuilder internal constructor(
@JsonIgnore
val properties: Properties,
) {
@JsonAnyGetter
internal fun getJsonProperties(): Map = properties.mergeWith(emptyMap())
operator fun plus(additive: Properties): CollectionItemBuilder = CollectionItemBuilder(
Properties(
data = additive.data ?: properties.data,
dataElementName = additive.dataElementName ?: properties.dataElementName,
prototypes = additive.prototypes ?: properties.prototypes,
)
)
class Properties internal constructor(
/**
* Data that will be used to create collection elements.
*/
val data: Property>?,
/**
* Name for accessing the next `data` element in the prototype. Working with this element is the same as with dictionaries.
* Default value: `it`.
*/
val dataElementName: Property?,
/**
* Array of `div` elements from which the collection elements will be created.
*/
val prototypes: Property>?,
) {
internal fun mergeWith(properties: Map): Map {
val result = mutableMapOf()
result.putAll(properties)
result.tryPutProperty("data", data)
result.tryPutProperty("data_element_name", dataElementName)
result.tryPutProperty("prototypes", prototypes)
return result
}
}
/**
* Can be created using the method [collectionItemBuilderPrototype].
*
* Required parameters: `div`.
*/
@Generated
class Prototype internal constructor(
@JsonIgnore
val properties: Properties,
) {
@JsonAnyGetter
internal fun getJsonProperties(): Map = properties.mergeWith(emptyMap())
operator fun plus(additive: Properties): Prototype = Prototype(
Properties(
div = additive.div ?: properties.div,
id = additive.id ?: properties.id,
selector = additive.selector ?: properties.selector,
)
)
class Properties internal constructor(
/**
* `Div` from which the collection elements will be created. In `Div`, you can use expressions using data from `data`. To access the next `data` element, you need to use the same prefix as in `data_element_prefix`.
*/
val div: Property?,
/**
* `id` of the element which is created from the prototype. May contain expression. Has higher priority than `div-base.id.`
*/
val id: Property?,
/**
* A condition that is used to select the prototype for the next element in the collection. If there is more than 1 true condition, the earlier prototype is selected. If none of the conditions are met, the element from `data` is skipped.
* Default value: `true`.
*/
val selector: Property?,
) {
internal fun mergeWith(properties: Map): Map {
val result = mutableMapOf()
result.putAll(properties)
result.tryPutProperty("div", div)
result.tryPutProperty("id", id)
result.tryPutProperty("selector", selector)
return result
}
}
}
}
/**
* @param data Data that will be used to create collection elements.
* @param dataElementName Name for accessing the next `data` element in the prototype. Working with this element is the same as with dictionaries.
* @param prototypes Array of `div` elements from which the collection elements will be created.
*/
@Generated
fun DivScope.collectionItemBuilder(
`use named arguments`: Guard = Guard.instance,
data: List? = null,
dataElementName: String? = null,
prototypes: List? = null,
): CollectionItemBuilder = CollectionItemBuilder(
CollectionItemBuilder.Properties(
data = valueOrNull(data),
dataElementName = valueOrNull(dataElementName),
prototypes = valueOrNull(prototypes),
)
)
/**
* @param data Data that will be used to create collection elements.
* @param dataElementName Name for accessing the next `data` element in the prototype. Working with this element is the same as with dictionaries.
* @param prototypes Array of `div` elements from which the collection elements will be created.
*/
@Generated
fun DivScope.collectionItemBuilderProps(
`use named arguments`: Guard = Guard.instance,
data: List? = null,
dataElementName: String? = null,
prototypes: List? = null,
) = CollectionItemBuilder.Properties(
data = valueOrNull(data),
dataElementName = valueOrNull(dataElementName),
prototypes = valueOrNull(prototypes),
)
/**
* @param data Data that will be used to create collection elements.
* @param dataElementName Name for accessing the next `data` element in the prototype. Working with this element is the same as with dictionaries.
* @param prototypes Array of `div` elements from which the collection elements will be created.
*/
@Generated
fun TemplateScope.collectionItemBuilderRefs(
`use named arguments`: Guard = Guard.instance,
data: ReferenceProperty>? = null,
dataElementName: ReferenceProperty? = null,
prototypes: ReferenceProperty>? = null,
) = CollectionItemBuilder.Properties(
data = data,
dataElementName = dataElementName,
prototypes = prototypes,
)
/**
* @param data Data that will be used to create collection elements.
* @param dataElementName Name for accessing the next `data` element in the prototype. Working with this element is the same as with dictionaries.
* @param prototypes Array of `div` elements from which the collection elements will be created.
*/
@Generated
fun CollectionItemBuilder.override(
`use named arguments`: Guard = Guard.instance,
data: List? = null,
dataElementName: String? = null,
prototypes: List? = null,
): CollectionItemBuilder = CollectionItemBuilder(
CollectionItemBuilder.Properties(
data = valueOrNull(data) ?: properties.data,
dataElementName = valueOrNull(dataElementName) ?: properties.dataElementName,
prototypes = valueOrNull(prototypes) ?: properties.prototypes,
)
)
/**
* @param data Data that will be used to create collection elements.
* @param dataElementName Name for accessing the next `data` element in the prototype. Working with this element is the same as with dictionaries.
* @param prototypes Array of `div` elements from which the collection elements will be created.
*/
@Generated
fun CollectionItemBuilder.defer(
`use named arguments`: Guard = Guard.instance,
data: ReferenceProperty>? = null,
dataElementName: ReferenceProperty? = null,
prototypes: ReferenceProperty>? = null,
): CollectionItemBuilder = CollectionItemBuilder(
CollectionItemBuilder.Properties(
data = data ?: properties.data,
dataElementName = dataElementName ?: properties.dataElementName,
prototypes = prototypes ?: properties.prototypes,
)
)
/**
* @param data Data that will be used to create collection elements.
*/
@Generated
fun CollectionItemBuilder.evaluate(
`use named arguments`: Guard = Guard.instance,
data: ExpressionProperty>? = null,
): CollectionItemBuilder = CollectionItemBuilder(
CollectionItemBuilder.Properties(
data = data ?: properties.data,
dataElementName = properties.dataElementName,
prototypes = properties.prototypes,
)
)
@Generated
fun CollectionItemBuilder.asList() = listOf(this)
/**
* @param div `Div` from which the collection elements will be created. In `Div`, you can use expressions using data from `data`. To access the next `data` element, you need to use the same prefix as in `data_element_prefix`.
* @param id `id` of the element which is created from the prototype. May contain expression. Has higher priority than `div-base.id.`
* @param selector A condition that is used to select the prototype for the next element in the collection. If there is more than 1 true condition, the earlier prototype is selected. If none of the conditions are met, the element from `data` is skipped.
*/
@Generated
fun DivScope.collectionItemBuilderPrototype(
`use named arguments`: Guard = Guard.instance,
div: Div? = null,
id: String? = null,
selector: Boolean? = null,
): CollectionItemBuilder.Prototype = CollectionItemBuilder.Prototype(
CollectionItemBuilder.Prototype.Properties(
div = valueOrNull(div),
id = valueOrNull(id),
selector = valueOrNull(selector),
)
)
/**
* @param div `Div` from which the collection elements will be created. In `Div`, you can use expressions using data from `data`. To access the next `data` element, you need to use the same prefix as in `data_element_prefix`.
* @param id `id` of the element which is created from the prototype. May contain expression. Has higher priority than `div-base.id.`
* @param selector A condition that is used to select the prototype for the next element in the collection. If there is more than 1 true condition, the earlier prototype is selected. If none of the conditions are met, the element from `data` is skipped.
*/
@Generated
fun DivScope.collectionItemBuilderPrototypeProps(
`use named arguments`: Guard = Guard.instance,
div: Div? = null,
id: String? = null,
selector: Boolean? = null,
) = CollectionItemBuilder.Prototype.Properties(
div = valueOrNull(div),
id = valueOrNull(id),
selector = valueOrNull(selector),
)
/**
* @param div `Div` from which the collection elements will be created. In `Div`, you can use expressions using data from `data`. To access the next `data` element, you need to use the same prefix as in `data_element_prefix`.
* @param id `id` of the element which is created from the prototype. May contain expression. Has higher priority than `div-base.id.`
* @param selector A condition that is used to select the prototype for the next element in the collection. If there is more than 1 true condition, the earlier prototype is selected. If none of the conditions are met, the element from `data` is skipped.
*/
@Generated
fun TemplateScope.collectionItemBuilderPrototypeRefs(
`use named arguments`: Guard = Guard.instance,
div: ReferenceProperty? = null,
id: ReferenceProperty? = null,
selector: ReferenceProperty? = null,
) = CollectionItemBuilder.Prototype.Properties(
div = div,
id = id,
selector = selector,
)
/**
* @param div `Div` from which the collection elements will be created. In `Div`, you can use expressions using data from `data`. To access the next `data` element, you need to use the same prefix as in `data_element_prefix`.
* @param id `id` of the element which is created from the prototype. May contain expression. Has higher priority than `div-base.id.`
* @param selector A condition that is used to select the prototype for the next element in the collection. If there is more than 1 true condition, the earlier prototype is selected. If none of the conditions are met, the element from `data` is skipped.
*/
@Generated
fun CollectionItemBuilder.Prototype.override(
`use named arguments`: Guard = Guard.instance,
div: Div? = null,
id: String? = null,
selector: Boolean? = null,
): CollectionItemBuilder.Prototype = CollectionItemBuilder.Prototype(
CollectionItemBuilder.Prototype.Properties(
div = valueOrNull(div) ?: properties.div,
id = valueOrNull(id) ?: properties.id,
selector = valueOrNull(selector) ?: properties.selector,
)
)
/**
* @param div `Div` from which the collection elements will be created. In `Div`, you can use expressions using data from `data`. To access the next `data` element, you need to use the same prefix as in `data_element_prefix`.
* @param id `id` of the element which is created from the prototype. May contain expression. Has higher priority than `div-base.id.`
* @param selector A condition that is used to select the prototype for the next element in the collection. If there is more than 1 true condition, the earlier prototype is selected. If none of the conditions are met, the element from `data` is skipped.
*/
@Generated
fun CollectionItemBuilder.Prototype.defer(
`use named arguments`: Guard = Guard.instance,
div: ReferenceProperty? = null,
id: ReferenceProperty? = null,
selector: ReferenceProperty? = null,
): CollectionItemBuilder.Prototype = CollectionItemBuilder.Prototype(
CollectionItemBuilder.Prototype.Properties(
div = div ?: properties.div,
id = id ?: properties.id,
selector = selector ?: properties.selector,
)
)
/**
* @param id `id` of the element which is created from the prototype. May contain expression. Has higher priority than `div-base.id.`
* @param selector A condition that is used to select the prototype for the next element in the collection. If there is more than 1 true condition, the earlier prototype is selected. If none of the conditions are met, the element from `data` is skipped.
*/
@Generated
fun CollectionItemBuilder.Prototype.evaluate(
`use named arguments`: Guard = Guard.instance,
id: ExpressionProperty? = null,
selector: ExpressionProperty? = null,
): CollectionItemBuilder.Prototype = CollectionItemBuilder.Prototype(
CollectionItemBuilder.Prototype.Properties(
div = properties.div,
id = id ?: properties.id,
selector = selector ?: properties.selector,
)
)
@Generated
fun CollectionItemBuilder.Prototype.asList() = listOf(this)
© 2015 - 2024 Weber Informatics LLC | Privacy Policy