TreeLikeData

interface TreeLikeData

Represents the value of a tree node.

Types

Companion
Link copied to clipboard
object Companion

Functions

asA
Link copied to clipboard
abstract fun <T : Any> asA(type: KClass<T>): T

Gets this value as an instance of type.

asListOf
Link copied to clipboard
abstract fun <T : Any> asListOf(type: KClass<T>): List<T>

Gets this value as a composite List of values of a given type.

asMapOf
Link copied to clipboard
abstract fun <T : Any> asMapOf(type: KClass<T>): Map<String, T>

Gets this value as a composite Map of values of a given type.

child
Link copied to clipboard
abstract fun child(index: Int): TreeLikeData

Gets the child node of this value (interpreted as a node representing a list) at a given index in the list.

abstract fun child(key: String): TreeLikeData

Gets the child node of this value at a given key.

childOrNull
Link copied to clipboard
abstract fun childOrNull(index: Int): TreeLikeData?

Gets the child node of this value (interpreted as a node representing a list) at a given index in the list.

abstract fun childOrNull(key: String): TreeLikeData?

Gets the child node of this value at a given key.

hasChild
Link copied to clipboard
abstract fun hasChild(index: Int): Boolean

Checks if this value is a node representing a list with a child node at the given index in the list.

abstract fun hasChild(key: String): Boolean

Checks if this value is a node with a child node at a given key.

stringify
Link copied to clipboard
abstract fun stringify(): String

Gets a serialized representation of this value.

tryGet
Link copied to clipboard
abstract fun <T : Any> tryGet(convert: TreeLikeData.() -> T): T?

Attempt to convert this value using the given convert function and return the converted value if it succeeds or null if it fails.

Properties

asBoolean
Link copied to clipboard
abstract val asBoolean: Boolean

Gets this value as a boolean primitive.

asList
Link copied to clipboard
abstract val asList: List<TreeLikeData>

Gets this value as a composite List of TreeLikeData values.

asMap
Link copied to clipboard
abstract val asMap: Map<String, TreeLikeData>

Gets this value as a composite Map of TreeLikeData values.

asNative
Link copied to clipboard
abstract val asNative: Any?

Gets this value as a combination of native primitive and composite types (Boolean, String, Number, Map, List).

asNumber
Link copied to clipboard
abstract val asNumber: Number

Gets this value as a number primitive (Int, Long or Double).

asString
Link copied to clipboard
abstract val asString: String

Gets this value as a string primitive.

children
Link copied to clipboard
abstract val children: List<TreeLikeData>

Gets the list of all child nodes (without their keys) of this value.

isBoolean
Link copied to clipboard
abstract val isBoolean: Boolean

Indicates whether this value is boolean.

isList
Link copied to clipboard
abstract val isList: Boolean

Indicates whether this value is a node with child nodes, which can be interpreted as a list.

isMap
Link copied to clipboard
abstract val isMap: Boolean

Indicates whether this value is a node with child nodes, which cannot be interpreted as a list.

isNull
Link copied to clipboard
abstract val isNull: Boolean

Indicates whether this value exists (false if so, true otherwise).

isNumber
Link copied to clipboard
abstract val isNumber: Boolean

Indicates whether this value is a number (i.e. any type of Number).

isString
Link copied to clipboard
abstract val isString: Boolean

Indicates whether this value is a string.

keys
Link copied to clipboard
abstract val keys: Set<String>

Gets the list of the keys of all child nodes of this value.

size
Link copied to clipboard
abstract val size: Int

Gets the number of child nodes of this value.

Inheritors

DatasyncValue
Link copied to clipboard

Extensions

asA
Link copied to clipboard
inline fun <T : Any> TreeLikeData.asA(): T

Shortcut to the TreeLikeData.asA method.

asListOf
Link copied to clipboard
inline fun <T : Any> TreeLikeData.asListOf(): List<T>

Shortcut to the TreeLikeData.asListOf method.

asMapOf
Link copied to clipboard
inline fun <T : Any> TreeLikeData.asMapOf(): Map<String, T>

Shortcut to the TreeLikeData.asMapOf method.