TreeLikeData

interface TreeLikeData

Represents the value of a tree node.

Inheritors

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
abstract val asBoolean: Boolean

Gets this value as a boolean primitive.

Link copied to clipboard
open val asDouble: Double

Converts this value to Double.

Link copied to clipboard
open val asInt: Int

Converts this value to Int.

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

Gets this value as a composite List of TreeLikeData values.

Link copied to clipboard
open val asLong: Long

Converts this value to Long.

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

Gets this value as a composite Map of TreeLikeData values.

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).

Link copied to clipboard
abstract val asNumber: Number

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

Link copied to clipboard
abstract val asString: String

Gets this value as a string primitive.

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

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

Link copied to clipboard
abstract val isBoolean: Boolean

Indicates whether this value is boolean.

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.

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.

Link copied to clipboard
abstract val isNull: Boolean

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

Link copied to clipboard
abstract val isNumber: Boolean

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

Link copied to clipboard
abstract val isString: Boolean

Indicates whether this value is a string.

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

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

Link copied to clipboard
abstract val size: Int

Gets the number of child nodes of this value.

Functions

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

Gets this value as an instance of type.

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

Shortcut to the TreeLikeData.asA method.

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.

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

Shortcut to the TreeLikeData.asListOf method.

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.

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

Shortcut to the TreeLikeData.asMapOf method.

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.

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.

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.

Link copied to clipboard
abstract fun stringify(): String

Gets a serialized representation of this value.

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.