Skip to content

ObservableMap

class ObservableMap<K, V>(map: MutableMap<K, V>, listener: (MutableMap<K, V>) -> Unit) : MutableMap<K, V> 

A MutableMap wrapper that invokes listener with the underlying map after every mutating operation. Used by mapField-style NBTHolder delegates to detect changes and persist/sync them.

Constructors

ObservableMap

constructor(map: MutableMap<K, V>, listener: (MutableMap<K, V>) -> Unit)

Properties

entries

open override val entries: MutableSet<MutableMap.MutableEntry<K, V>>

keys

open override val keys: MutableSet<K>

size

open override val size: Int

values

open override val values: MutableCollection<V>

Functions

clear

open override fun clear()

compute

open override fun compute(key: K, remappingFunction: BiFunction<in K, in V?, out V?>): V?

computeIfAbsent

open override fun computeIfAbsent(key: K, mappingFunction: Function<in K, out V>): V

computeIfPresent

open override fun computeIfPresent(key: K, remappingFunction: BiFunction<in K, in V & Any, out V?>): V?

containsKey

open override fun containsKey(key: K): Boolean

containsValue

open override fun containsValue(value: V): Boolean

get

open operator override fun get(key: K): V?

isEmpty

open override fun isEmpty(): Boolean

merge

open override fun merge(
    key: K, 
    value: V & Any, 
    remappingFunction: BiFunction<in V & Any, in V & Any, out V?>
): V?

put

open override fun put(key: K, value: V): V?

putAll

open override fun putAll(from: Map<out K, V>)

putIfAbsent

open override fun putIfAbsent(key: K, value: V): V?

remove

open override fun remove(key: K): V?
open override fun remove(key: K, value: V): Boolean

replace

open override fun replace(key: K, value: V): V?
open override fun replace(
    key: K, 
    oldValue: V, 
    newValue: V
): Boolean

replaceAll

open override fun replaceAll(function: BiFunction<in K, in V, out V>)