divkit.dsl.DownloadCallbacks.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
/**
* Callbacks that are called after [data loading](../../interaction#loading-data).
*
* Can be created using the method [downloadCallbacks].
*/
@Generated
class DownloadCallbacks internal constructor(
@JsonIgnore
val properties: Properties,
) {
@JsonAnyGetter
internal fun getJsonProperties(): Map = properties.mergeWith(emptyMap())
operator fun plus(additive: Properties): DownloadCallbacks = DownloadCallbacks(
Properties(
onFailActions = additive.onFailActions ?: properties.onFailActions,
onSuccessActions = additive.onSuccessActions ?: properties.onSuccessActions,
)
)
class Properties internal constructor(
/**
* Actions in case of unsuccessful loading if the host reported it or the waiting time expired.
*/
val onFailActions: Property>?,
/**
* Actions in case of successful loading.
*/
val onSuccessActions: Property>?,
) {
internal fun mergeWith(properties: Map): Map {
val result = mutableMapOf()
result.putAll(properties)
result.tryPutProperty("on_fail_actions", onFailActions)
result.tryPutProperty("on_success_actions", onSuccessActions)
return result
}
}
}
/**
* @param onFailActions Actions in case of unsuccessful loading if the host reported it or the waiting time expired.
* @param onSuccessActions Actions in case of successful loading.
*/
@Generated
fun DivScope.downloadCallbacks(
`use named arguments`: Guard = Guard.instance,
onFailActions: List? = null,
onSuccessActions: List? = null,
): DownloadCallbacks = DownloadCallbacks(
DownloadCallbacks.Properties(
onFailActions = valueOrNull(onFailActions),
onSuccessActions = valueOrNull(onSuccessActions),
)
)
/**
* @param onFailActions Actions in case of unsuccessful loading if the host reported it or the waiting time expired.
* @param onSuccessActions Actions in case of successful loading.
*/
@Generated
fun DivScope.downloadCallbacksProps(
`use named arguments`: Guard = Guard.instance,
onFailActions: List? = null,
onSuccessActions: List? = null,
) = DownloadCallbacks.Properties(
onFailActions = valueOrNull(onFailActions),
onSuccessActions = valueOrNull(onSuccessActions),
)
/**
* @param onFailActions Actions in case of unsuccessful loading if the host reported it or the waiting time expired.
* @param onSuccessActions Actions in case of successful loading.
*/
@Generated
fun TemplateScope.downloadCallbacksRefs(
`use named arguments`: Guard = Guard.instance,
onFailActions: ReferenceProperty>? = null,
onSuccessActions: ReferenceProperty>? = null,
) = DownloadCallbacks.Properties(
onFailActions = onFailActions,
onSuccessActions = onSuccessActions,
)
/**
* @param onFailActions Actions in case of unsuccessful loading if the host reported it or the waiting time expired.
* @param onSuccessActions Actions in case of successful loading.
*/
@Generated
fun DownloadCallbacks.override(
`use named arguments`: Guard = Guard.instance,
onFailActions: List? = null,
onSuccessActions: List? = null,
): DownloadCallbacks = DownloadCallbacks(
DownloadCallbacks.Properties(
onFailActions = valueOrNull(onFailActions) ?: properties.onFailActions,
onSuccessActions = valueOrNull(onSuccessActions) ?: properties.onSuccessActions,
)
)
/**
* @param onFailActions Actions in case of unsuccessful loading if the host reported it or the waiting time expired.
* @param onSuccessActions Actions in case of successful loading.
*/
@Generated
fun DownloadCallbacks.defer(
`use named arguments`: Guard = Guard.instance,
onFailActions: ReferenceProperty>? = null,
onSuccessActions: ReferenceProperty>? = null,
): DownloadCallbacks = DownloadCallbacks(
DownloadCallbacks.Properties(
onFailActions = onFailActions ?: properties.onFailActions,
onSuccessActions = onSuccessActions ?: properties.onSuccessActions,
)
)
@Generated
fun DownloadCallbacks.asList() = listOf(this)