LockableValueDsl

abstract class LockableValueDsl : ValueDsl(source)

Extension of ValueDsl that adds locking functionality to prevent further modifications.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Indicates whether the DSL is locked.

Functions

Link copied to clipboard
protected open fun <I, O> conditional(initial: I, beforeGet: DslValue<O, *>.(I) -> Boolean = { true }, beforeSet: DslValue<O, *>.(O) -> Boolean = { true }, getTransform: (I) -> O, setTransform: (O) -> I, validateGet: KProperty<*>.(O) -> Boolean = { true }, validateSet: KProperty<*>.(I) -> Boolean = { true }, getBypassedHooksValue: (DslValue.BypassedHooks<O>) -> Unit = {}, messageBuilder: KProperty<*>.() -> Any = { "Invalid value for property $name." }): ValueProperty<I, O>

Creates a property delegate with validation and transformation logic.

Link copied to clipboard
protected open fun <T> list(initial: MutableList<T> = mutableListOf(), getTransform: DslMutableList<T>.(T) -> T = { it }, setTransform: DslMutableList<T>.(T) -> T = { it }, beforeGet: DslMutableList<T>.(index: Int) -> Unit = {}, beforeSet: DslMutableList<T>.(index: Int, element: T) -> Unit = { _, _ -> }, beforeRemove: DslMutableList<T>.(index: Int) -> Unit = {}, beforeAccess: DslMutableList<T>.() -> Unit = {}, accessTransform: DslMutableList<T>.() -> MutableList<T> = { this }, getDslMutableList: (DslMutableList<T>) -> Unit = {}): DslReadOnlyListProperty<T>

Creates a non-replaceable mutable list property delegate with element transformations and a hook.

Link copied to clipboard
protected fun lock()

Locks the DSL, preventing further modifications.

Link copied to clipboard
protected open fun <T> optional(beforeGet: DslValue<T?, *>.(T?) -> Unit = {}, beforeSet: DslValue<T?, *>.(T?) -> Unit = {}, getTransform: (T?) -> T? = { it }, setTransform: (T?) -> T? = { it }, afterGet: DslValue<T?, *>.(T?) -> Unit = {}, afterSet: DslValue<T?, *>.(T?) -> Unit = {}, getBypassedHooksValue: (DslValue.BypassedHooks<T?>) -> Unit = {}): ValueProperty<T?, T?>

Creates an optional property delegate (nullable).

Link copied to clipboard
protected open fun <T> prepared(initial: T, beforeGet: DslValue<T, *>.(T) -> Unit = {}, beforeSet: DslValue<T, *>.(T) -> Unit = {}, getTransform: (T) -> T = { it }, setTransform: (T) -> T = { it }, afterGet: DslValue<T, *>.(T) -> Unit = {}, afterSet: DslValue<T, *>.(T) -> Unit = {}, getBypassedHooksValue: (DslValue.BypassedHooks<T>) -> Unit = {}): ValueProperty<T, T>

Creates a property delegate with a default value and optional transformations.

Link copied to clipboard
protected open fun <T> replaceableList(initial: MutableList<T> = mutableListOf(), getTransform: (T) -> T = { it }, setTransform: (T) -> T = { it }, beforeGet: DslMutableList<T>.(index: Int) -> Unit = {}, beforeSet: DslMutableList<T>.(index: Int, element: T) -> Unit = { _, _ -> }, beforeRemove: DslMutableList<T>.(index: Int) -> Unit = {}, beforeAccess: DslMutableList<T>.() -> Unit = {}, beforeReplace: DslMutableList<T>.(MutableList<T>) -> Unit = {}, accessTransform: DslMutableList<T>.() -> MutableList<T> = { this }, getDslMutableList: (DslMutableList<T>) -> Unit = {}): ListProperty<T, T>

Creates a replaceable list property delegate with element transformations and hooks.

Link copied to clipboard
protected open fun <T> required(beforeGet: DslValue<T, *>.(T?) -> Unit = {}, beforeSet: DslValue<T, *>.(T?) -> Unit = {}, getTransform: (T) -> T = { it }, setTransform: (T) -> T = { it }, validateGet: KProperty<*>.(T) -> Boolean = { true }, validateSet: KProperty<*>.(T) -> Boolean = { true }, getBypassedHooksValue: (DslValue.BypassedHooks<T>) -> Unit = {}, messageBuilder: KProperty<*>.() -> Any = { "Property $name is required and cannot be null." }): ValueProperty<T?, T>

Creates a required (non-null) property delegate.

Link copied to clipboard
inline fun <T, R> MutableList<T>.tryBypassHooks(failed: () -> Unit = {}, noinline block: MutableList<T>.() -> R): R?

Attempts to bypass hooks on a MutableList if it is an instance of DslMutableList.

Link copied to clipboard
protected open override fun <I, O> value(initial: I, beforeGet: DslValue<O, *>.(I) -> Unit, beforeSet: DslValue<O, *>.(O) -> Unit, getTransform: (I) -> O, setTransform: (O) -> I, afterGet: DslValue<O, *>.(O) -> Unit, afterSet: DslValue<O, *>.(I) -> Unit, getBypassedHooksValue: (DslValue.BypassedHooks<O>) -> Unit): ValueProperty<I, O>

Creates a property delegate with custom get/set transformations.

protected open override fun <I, O> value(initial: MutableList<I>, getTransform: DslMutableList<O>.(I) -> O, setTransform: DslMutableList<O>.(O) -> I, beforeGet: DslMutableList<O>.(Int) -> Unit, beforeSet: DslMutableList<O>.(Int, O) -> Unit, beforeRemove: DslMutableList<O>.(Int) -> Unit, beforeAccess: DslMutableList<O>.() -> Unit, beforeReplace: DslMutableList<O>.(MutableList<O>) -> Unit, accessTransform: DslMutableList<O>.() -> MutableList<O>, getDslMutableList: (DslMutableList<O>) -> Unit): ListProperty<I, O>

Creates a read-write list property delegate with transformations and hooks.

protected open fun <I, O> value(initial: MutableList<I> = mutableListOf(), getTransform: DslMutableList<O>.(I) -> O, setTransform: DslMutableList<O>.(O) -> I, beforeGet: DslMutableList<O>.(index: Int) -> Unit = {}, beforeSet: DslMutableList<O>.(index: Int, element: O) -> Unit = { _, _ -> }, beforeRemove: DslMutableList<O>.(index: Int) -> Unit = {}, beforeAccess: DslMutableList<O>.() -> Unit = {}, accessTransform: DslMutableList<O>.() -> MutableList<O> = { this }, getDslMutableList: (DslMutableList<O>) -> Unit = {}): DslReadOnlyListProperty<O>

Creates a mutable list property delegate with transformations and a hook.