OptionalItem

open class OptionalItem<T@JvmOverloads() constructor(spec: Spec, name: String, default: T, description: String, type: JavaType?, nullable: Boolean) : Item<T>

Optional item with default value.

Before associated with specified value, default value will be returned when accessing. After associated with specified value, the specified value will be returned when accessing.

Constructors

OptionalItem
Link copied to clipboard
fun <T> OptionalItem(spec: Spec, name: String, default: 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.
default
Link copied to clipboard
val default: T
Default value returned before associating this item with specified value.
description
Link copied to clipboard
val description: String
Description for this item.
isLazy
Link copied to clipboard
open val isLazy: Boolean
Whether this is a lazy item or not.
isOptional
Link copied to clipboard
open override val isOptional: Boolean = true
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.
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