public class RMap<K,V> extends RCollection<Map.Entry<K,V>> implements Map<K,V>
put(K, V)
and other default mechanisms for
updating the map will not trigger a notification if the updated value is equal to the
value already in the map. Use putForce(K, V)
to force a notification. Similarly, remove(java.lang.Object)
will only generate a notification if a mapping for the specified key existed, use
removeForce(K)
to force a notification.Modifier and Type | Class and Description |
---|---|
static class |
RMap.Listener<K,V>
An interface for publishing map events to listeners.
|
Reactor.RListener
Constructor and Description |
---|
RMap(Map<K,V> impl)
Creates a reactive map with the supplied underlying map implementation.
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
Connection |
connect(RMap.Listener<? super K,? super V> listener)
Connects the supplied listener to this map, such that it will be notified on puts and
removes.
|
Connection |
connectNotify(RMap.Listener<? super K,? super V> listener)
Invokes
onPut for all existing entries and then connects listener . |
boolean |
containsKey(Object key) |
ValueView<Boolean> |
containsKeyView(K key)
Returns a value view that models whether the specified key is contained in this map.
|
boolean |
containsValue(Object value) |
static <K,V> RMap<K,V> |
create()
Creates a reactive map that uses a
HashMap as its underlying implementation. |
static <K,V> RMap<K,V> |
create(Map<K,V> impl)
Creates a reactive map with the supplied underlying map implementation.
|
void |
disconnect(RMap.Listener<? super K,? super V> listener)
Disconnects the supplied listener from this map if listen was called with it.
|
Set<Map.Entry<K,V>> |
entrySet() |
boolean |
equals(Object other) |
V |
get(Object key) |
V |
getOrElse(K key,
V defaultValue)
Returns the mapping for
key or defaultValue if there is no mapping for
key . |
ValueView<V> |
getView(K key)
Returns a value view that models the mapping of the specified key in this map.
|
int |
hashCode() |
boolean |
isEmpty() |
Set<K> |
keySet() |
V |
put(K key,
V value) |
void |
putAll(Map<? extends K,? extends V> map) |
V |
putForce(K key,
V value)
Updates the mapping with the supplied key and value, and notifies registered listeners
regardless of whether the new value is equal to the old value.
|
V |
remove(Object rawKey) |
V |
removeForce(K key)
Removes the mapping associated with the supplied key, and notifies registered listeners
regardless of whether a previous mapping existed or not.
|
int |
size()
Returns the number of elements in this collection.
|
String |
toString() |
Collection<V> |
values() |
isEmptyView, isNonEmptyView, sizeView
clearConnections, hasConnections
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public static <K,V> RMap<K,V> create()
HashMap
as its underlying implementation.public static <K,V> RMap<K,V> create(Map<K,V> impl)
public Connection connect(RMap.Listener<? super K,? super V> listener)
public Connection connectNotify(RMap.Listener<? super K,? super V> listener)
onPut
for all existing entries and then connects listener
. Note that
the previous value supplied to the onPut
calls will be null.public void disconnect(RMap.Listener<? super K,? super V> listener)
public V getOrElse(K key, V defaultValue)
key
or defaultValue
if there is no mapping for
key
. NOTE: this method assumes the map does not contain a mapping to null
. A mapping to null
will be treated as if the mapping does not exist.public V putForce(K key, V value)
public V removeForce(K key)
public ValueView<Boolean> containsKeyView(K key)
null
. The view
will retain a connection to this map for as long as it has connections of its own.public ValueView<V> getView(K key)
public int size()
RCollection
public boolean containsKey(Object key)
containsKey
in interface Map<K,V>
public boolean containsValue(Object value)
containsValue
in interface Map<K,V>
public int hashCode()
public boolean equals(Object other)
Copyright © 2017. All rights reserved.