LazyItem

open class LazyItem<T@JvmOverloads() constructor(spec: Spec, name: String, thunk: (config: ItemContainer) -> T, description: String, type: JavaType?, nullable: Boolean) : Item<T>

Lazy item evaluated value every time from thunk before associated with specified value.

Before associated with specified value, value evaluated from thunk will be returned when accessing. After associated with specified value, the specified value will be returned when accessing. Returned value of the thunk will not be cached. The thunk will be evaluated every time when needed to reflect modifying of other values in config.

Constructors

LazyItem
Link copied to clipboard
fun <T> LazyItem(spec: Spec, name: String, thunk: (config: ItemContainer) -> T, description: String = "", type: JavaType? = null, nullable: Boolean = false)

Functions

afterSet
Link copied to clipboard
fun afterSet(afterSetFunction: (config: Config, T) -> Unit): Handler
Subscribe the update event of this item after every set operation.
beforeSet
Link copied to clipboard
fun beforeSet(beforeSetFunction: (config: Config, T) -> Unit): Handler
Subscribe the update event of this item before every set operation.
notifyAfterSet
Link copied to clipboard
fun notifyAfterSet(config: Config, value: Any?)
notifyBeforeSet
Link copied to clipboard
fun notifyBeforeSet(config: Config, value: Any?)
notifySet
Link copied to clipboard
fun notifySet(value: Any?)
onSet
Link copied to clipboard
fun onSet(onSetFunction: (T) -> Unit): Handler
Subscribe the update event of this item.

Properties

asLazyItem
Link copied to clipboard
val asLazyItem: LazyItem<T>
Cast this item to a lazy item.
asOptionalItem
Link copied to clipboard
val asOptionalItem: OptionalItem<T>
Cast this item to an optional item.
asRequiredItem
Link copied to clipboard
val asRequiredItem: RequiredItem<T>
Cast this item to a required item.
description
Link copied to clipboard
val description: String
Description for this item.
isLazy
Link copied to clipboard
open override val isLazy: Boolean = true
Whether this is a lazy item or not.
isOptional
Link copied to clipboard
open val isOptional: Boolean
Whether this is an optional item or not.
isRequired
Link copied to clipboard
open val isRequired: Boolean
Whether this is a required item or not.
name
Link copied to clipboard
val name: String
Item name without prefix.
nullable
Link copied to clipboard
val nullable: Boolean
path
Link copied to clipboard
val path: Path
Item path without prefix.
spec
Link copied to clipboard
val spec: Spec
Config spec that contains this item.
thunk
Link copied to clipboard
val thunk: (config: ItemContainer) -> T
Thunk used to evaluate value for this item.
type
Link copied to clipboard
val type: JavaType
Type of value that can be associated with this item.

Sources

jvm source
Link copied to clipboard