Package com.imyeyu.java.obs
Class ObservableMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
com.imyeyu.java.obs.ObservableMap<K,V>
- Type Parameters:
K- 键类型V- 值类型
- All Implemented Interfaces:
Serializable,Cloneable,Map<K,V>
可观察映射,支持监听键值对新增、更新和删除事件
- Since:
- 2024-09-01 18:32
- Author:
- 夜雨
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChangeListener(MapChangeListener<K, V> listener) 添加映射变更监听器写入键值对并在必要时通知监听器void批量写入键值对删除指定键并通知监听器boolean仅当键值都匹配时删除并通知监听器voidremoveChangeListener(MapChangeListener<K, V> listener) 移除映射变更监听器Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, newHashMap, putIfAbsent, replace, replace, replaceAll, size, valuesMethods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Constructor Details
-
ObservableMap
public ObservableMap()
-
-
Method Details
-
addChangeListener
添加映射变更监听器- Parameters:
listener- 映射变更监听器
-
removeChangeListener
移除映射变更监听器- Parameters:
listener- 映射变更监听器
-
put
写入键值对并在必要时通知监听器 -
putAll
批量写入键值对 -
remove
删除指定键并通知监听器 -
remove
仅当键值都匹配时删除并通知监听器
-