BaseConfig

open class BaseConfig(name: String, parent: BaseConfig?, mapper: ObjectMapper, specsInLayer: MutableList<Spec>, featuresInLayer: MutableMap<Feature, Boolean>, nodeByItem: MutableMap<Item<*>, BaseConfig.ItemNode>, tree: TreeNode, hasChildren: BaseConfig.Value<Boolean>, beforeSetFunctions: MutableList<(item: Item<*>, value: Any?) -> Unit>, afterSetFunctions: MutableList<(item: Item<*>, value: Any?) -> Unit>, beforeLoadFunctions: MutableList<(source: Source) -> Unit>, afterLoadFunctions: MutableList<(source: Source) -> Unit>, lock: ReentrantReadWriteLock) : Config

The default implementation for Config.

Constructors

BaseConfig
Link copied to clipboard
fun BaseConfig(name: String = "", parent: BaseConfig? = null, mapper: ObjectMapper = createDefaultMapper(), specsInLayer: MutableList<Spec> = mutableListOf(), featuresInLayer: MutableMap<Feature, Boolean> = mutableMapOf(), nodeByItem: MutableMap<Item<*>, BaseConfig.ItemNode> = mutableMapOf(), tree: TreeNode = ContainerNode.placeHolder(), hasChildren: BaseConfig.Value<Boolean> = Value(false), beforeSetFunctions: MutableList<(item: Item<*>, value: Any?) -> Unit> = mutableListOf(), afterSetFunctions: MutableList<(item: Item<*>, value: Any?) -> Unit> = mutableListOf(), beforeLoadFunctions: MutableList<(source: Source) -> Unit> = mutableListOf(), afterLoadFunctions: MutableList<(source: Source) -> Unit> = mutableListOf(), lock: ReentrantReadWriteLock = ReentrantReadWriteLock())

Types

ItemNode
Link copied to clipboard
class ItemNode(value: BaseConfig.ValueState, item: Item<*>) : ValueNode
Value
Link copied to clipboard
data class Value<T>(value: T)
ValueState
Link copied to clipboard
sealed class ValueState

Functions

addAfterLoadFunction
Link copied to clipboard
open fun addAfterLoadFunction(afterLoadFunction: (source: Source) -> Unit)
addAfterSetFunction
Link copied to clipboard
open fun addAfterSetFunction(afterSetFunction: (item: Item<*>, value: Any?) -> Unit)
addBeforeLoadFunction
Link copied to clipboard
open fun addBeforeLoadFunction(beforeLoadFunction: (source: Source) -> Unit)
addBeforeSetFunction
Link copied to clipboard
open fun addBeforeSetFunction(beforeSetFunction: (item: Item<*>, value: Any?) -> Unit)
addItem
Link copied to clipboard
open override fun addItem(item: Item<*>, prefix: String)
Load item into facade layer with the specified prefix.
addSpec
Link copied to clipboard
open override fun addSpec(spec: Spec)
Load items in specified config spec into facade layer.
afterLoad
Link copied to clipboard
open override fun afterLoad(afterLoadFunction: (source: Source) -> Unit): Handler
Subscribe the update event after every load operation.
afterSet
Link copied to clipboard
open override fun afterSet(afterSetFunction: (item: Item<*>, value: Any?) -> Unit): Handler
Subscribe the update event after every set operation.
at
Link copied to clipboard
open override fun at(path: String): Config
Returns sub-config in the specified path.
beforeLoad
Link copied to clipboard
open override fun beforeLoad(beforeLoadFunction: (source: Source) -> Unit): Handler
Subscribe the update event before every load operation.
beforeSet
Link copied to clipboard
open override fun beforeSet(beforeSetFunction: (item: Item<*>, value: Any?) -> Unit): Handler
Subscribe the update event before every set operation.
clear
Link copied to clipboard
open override fun clear()
Remove all values from the facade layer of this config.
clearAll
Link copied to clipboard
open override fun clearAll()
Remove all values from all layers of this config.
contains
Link copied to clipboard
open operator override fun contains(item: Item<*>): Boolean
Whether this item container contains specified item or not.
open operator override fun contains(name: String): Boolean
Whether this item container contains item with specified name or not.
open operator override fun contains(path: Path): Boolean
Whether this item container contains the specified path or not.
containsRequired
Link copied to clipboard
open override fun containsRequired(): Boolean
Whether all required items have values or not.
disable
Link copied to clipboard
open override fun disable(feature: Feature): Config
Disables the specified feature and returns this config.
enable
Link copied to clipboard
open override fun enable(feature: Feature): Config
Enables the specified feature and returns this config.
forEach
Link copied to clipboard
open fun forEach(p0: Consumer<in Item<*>>)
from
Link copied to clipboard
open fun from(): DefaultLoaders
Returns default loaders for this config.
get
Link copied to clipboard
open operator override fun <T> get(item: Item<T>): T
Get associated value with specified item.
open operator override fun <T> get(name: String): T
Get associated value with specified item name.
getItemOrNull
Link copied to clipboard
open fun getItemOrNull(name: String): Item<*>?
getOrNull
Link copied to clipboard
open override fun <T> getOrNull(item: Item<T>): T?
Returns associated value if specified item exists, null otherwise.
open override fun <T> getOrNull(name: String): T?
Returns associated value if specified item name exists, null otherwise.
open fun getOrNull(item: Item<*>, errorWhenNotFound: Boolean, errorWhenGetDefault: Boolean = false, lazyContext: ItemContainer = this): Any?
invoke
Link copied to clipboard
open operator fun <T> invoke(name: String): T
Get associated value with specified item name.
isEnabled
Link copied to clipboard
open override fun isEnabled(feature: Feature): Boolean
Check whether the specified feature is enabled or not.
iterator
Link copied to clipboard
open operator override fun iterator(): Iterator<Item<*>>
Returns iterator of items in this item container.
lazySet
Link copied to clipboard
open override fun <T> lazySet(item: Item<T>, thunk: (config: ItemContainer) -> T)
Associate item with specified thunk, which can be used to evaluate value for the item.
open override fun <T> lazySet(name: String, thunk: (config: ItemContainer) -> T)
Find item with specified name, and associate item with specified thunk, which can be used to evaluate value for the item.
lock
Link copied to clipboard
open override fun <T> lock(action: () -> T): T
Executes the given action after locking the facade layer of this config.
nameOf
Link copied to clipboard
open override fun nameOf(item: Item<*>): String
Returns the qualified name of the specified item.
pathOf
Link copied to clipboard
open fun pathOf(item: Item<*>): Path
Returns the qualified path of the specified item.
plus
Link copied to clipboard
open operator override fun plus(config: Config): Config
Returns a config overlapped by the specified facade config.
property
Link copied to clipboard
open override fun <T> property(item: Item<T>): ReadWriteProperty<Any?, T>
Returns a property that can read/set associated value for specified item.
open override fun <T> property(name: String): ReadWriteProperty<Any?, T>
Returns a property that can read/set associated value for item with specified name.
rawSet
Link copied to clipboard
open override fun rawSet(item: Item<*>, value: Any?)
Associate item with specified value without type checking.
removeAfterLoadFunction
Link copied to clipboard
open fun removeAfterLoadFunction(afterLoadFunction: (source: Source) -> Unit)
removeAfterSetFunction
Link copied to clipboard
open fun removeAfterSetFunction(afterSetFunction: (item: Item<*>, value: Any?) -> Unit)
removeBeforeLoadFunction
Link copied to clipboard
open fun removeBeforeLoadFunction(beforeLoadFunction: (source: Source) -> Unit)
removeBeforeSetFunction
Link copied to clipboard
open fun removeBeforeSetFunction(beforeSetFunction: (item: Item<*>, value: Any?) -> Unit)
set
Link copied to clipboard
open operator override fun <T> set(item: Item<T>, value: T)
Associate item with specified value.
open operator override fun <T> set(name: String, value: T)
Find item with specified name, and associate it with specified value.
spliterator
Link copied to clipboard
open fun spliterator(): Spliterator<Item<*>>
toMap
Link copied to clipboard
open override fun toMap(): Map<String, Any>
Returns a map in key-value format for this config.
toString
Link copied to clipboard
open override fun toString(): String
unset
Link copied to clipboard
open override fun unset(item: Item<*>)
Discard associated value of specified item.
open override fun unset(name: String)
Discard associated value of item with specified name.
validateRequired
Link copied to clipboard
open override fun validateRequired(): Config
Validate whether all required items have values or not.
withFallback
Link copied to clipboard
open override fun withFallback(config: Config): Config
Returns a config backing by the specified fallback config.
withLayer
Link copied to clipboard
open override fun withLayer(name: String): BaseConfig
Returns a child config of this config with specified name.
withLoadTrigger
Link copied to clipboard
open override fun withLoadTrigger(description: String, trigger: (config: Config, load: (source: Source) -> Unit) -> Unit): Config
Returns a child config containing values loaded by specified trigger.
withPrefix
Link copied to clipboard
open override fun withPrefix(prefix: String): Config
Returns config with the specified additional prefix.
withSource
Link copied to clipboard
open override fun withSource(source: Source): Config
Returns a child config containing values from specified source.

Properties

from
Link copied to clipboard
open val from: DefaultLoaders
Returns default loaders for this config.
items
Link copied to clipboard
open val items: List<Item<*>>
List of items in this item container.
itemWithNames
Link copied to clipboard
open override val itemWithNames: List<Pair<Item<*>, String>>
List of items with the corresponding qualified names in this item container.
mapper
Link copied to clipboard
open override val mapper: ObjectMapper
Returns ObjectMapper using to map from source to value in config.
name
Link copied to clipboard
open override val name: String
Name of facade layer of config.
nameOfItems
Link copied to clipboard
open val nameOfItems: List<String>
List of qualified names of items in this item container.
parent
Link copied to clipboard
open override val parent: BaseConfig? = null
Returns parent of this config, or null if this config is a root config.
source
Link copied to clipboard
open val source: Source
sources
Link copied to clipboard
open override val sources: List<Source>
List of sources from all layers of this config.
specs
Link copied to clipboard
open override val specs: List<Spec>
List of config specs from all layers of this config.

Inheritors

MergedConfig
Link copied to clipboard

Sources

jvm source
Link copied to clipboard