AbstractKpaStructMap

abstract class AbstractKpaStructMap<E>(backingMap: Map<String, E>) : KpaStruct(source)

Convenience base class for KpaStruct implementations backed by a Map with String keys and native values of type E.

Implements get, contains, keys, and toMap by delegating to backingMap and wrapElement. Subclasses must provide factory and wrapElement; everything else is handled here.

This base class is only suitable for adapters whose native map type already uses String keys. Adapters whose native map has non-string keys (e.g. yamlkt's YamlMap keyed by YamlElement) must implement KpaStruct directly.

Parameters

backingMap

The map of string keys to native values to expose.

Type Parameters

E

The native value element type stored in the backing map.

Constructors

Link copied to clipboard
constructor(backingMap: Map<String, E>)

Properties

Link copied to clipboard
open override val keys: Set<String>

The set of keys present in backingMap.

Functions

Link copied to clipboard

Returns the boolean value at pointer, or null if the path is absent or the value is not a boolean primitive.

Parses path via KPointer.from and returns the boolean value at that path, or null if absent or not a boolean.

Link copied to clipboard
open operator override fun contains(key: String): Boolean
Link copied to clipboard

Returns the numeric value as Double at pointer, or null if the path is absent or the value is not a numeric primitive.

Parses path via KPointer.from and returns the numeric value as Double at that path, or null if absent or not numeric.

Link copied to clipboard
open operator override fun get(key: String): KpaElement?
Link copied to clipboard
operator fun KpaStruct.get(pointer: KPointer): KpaElement?

Returns the KpaElement at the path identified by pointer, or null if a key along the path is absent. Returns the receiver if pointer is the root pointer.

Link copied to clipboard

Returns the KpaList at pointer, or null if the path is absent or the value is not a list.

Parses path via KPointer.from and returns the KpaList at that path, or null if absent or not a list.

Link copied to clipboard
fun KpaStruct.longAt(pointer: KPointer): Long?

Returns the numeric value as Long at pointer, or null if the path is absent, the value is not a numeric primitive, or the value has a fractional component.

Parses path via KPointer.from and returns the numeric value as Long at that path, or null if absent, not numeric, or has a fractional component.

Link copied to clipboard

Returns the KpaPrimitive at pointer, or null if the path is absent or the value is not a primitive.

Parses path via KPointer.from and returns the KpaPrimitive at that path, or null if absent or not a primitive.

Link copied to clipboard
inline fun <B : Any> KpaElement.requireBacking(libraryName: String): B

Unwraps this KpaElement to its native backing value of type B, or throws if this element is not a BackedKpaElement whose backing is of type B.

Link copied to clipboard

Returns the string value at pointer, or null if the path is absent or the value is not a string primitive.

Parses path via KPointer.from and returns the string value at that path, or null if absent or not a string.

Link copied to clipboard

Returns the KpaStruct at pointer, or null if the path is absent or the value is not a struct.

Parses path via KPointer.from and returns the KpaStruct at that path, or null if absent or not a struct.

Link copied to clipboard
open override fun toMap(): Map<String, KpaElement>