K - the type of keys maintained by this mapV - the type of mapped values@Experimental(value=STATE) public interface MapState<K,V> extends State
ReadableState cell mapping keys to values.
Implementations of this form of state are expected to implement map operations efficiently as supported by some associated backing key-value store.
| Modifier and Type | Method and Description |
|---|---|
ReadableState<V> |
computeIfAbsent(K key,
java.util.function.Function<? super K,? extends V> mappingFunction)
A deferred read-followed-by-write.
|
ReadableState<java.lang.Iterable<java.util.Map.Entry<K,V>>> |
entries()
Returns an
Iterable over the key-value pairs contained in this map. |
ReadableState<V> |
get(K key)
A deferred lookup, using null values if the item is not found.
|
ReadableState<V> |
getOrDefault(K key,
V defaultValue)
A deferred lookup.
|
ReadableState<java.lang.Boolean> |
isEmpty()
Returns a
ReadableState whose ReadableState.read() method will return true if
this state is empty at the point when that ReadableState.read() call returns. |
ReadableState<java.lang.Iterable<K>> |
keys()
Returns an
Iterable over the keys contained in this map. |
void |
put(K key,
V value)
Associates the specified value with the specified key in this state.
|
default ReadableState<V> |
putIfAbsent(K key,
V value)
A deferred read-followed-by-write.
|
void |
remove(K key)
Remove the mapping for a key from this map if it is present.
|
ReadableState<java.lang.Iterable<V>> |
values()
Returns an
Iterable over the values contained in this map. |
void put(K key, V value)
Changes will not be reflected in the results returned by previous calls to ReadableState.read() on the results any of the reading methods (get(K), keys(),
values(), and entries()).
default ReadableState<V> putIfAbsent(K key, V value)
When read() is called on the result or state is committed, it forces a read of the
map and reconciliation with any pending modifications.
If the specified key is not already associated with a value (or is mapped to null)
associates it with the given value and returns null, else returns the current value.
Changes will not be reflected in the results returned by previous calls to ReadableState.read() on the results any of the reading methods (get(K), keys(),
values(), and entries()).
ReadableState<V> computeIfAbsent(K key, java.util.function.Function<? super K,? extends V> mappingFunction)
When read() is called on the result or state is committed, it forces a read of the
map and reconciliation with any pending modifications.
If the specified key is not already associated with a value (or is mapped to null)
associates it with the computed and returns null, else returns the current value.
Changes will not be reflected in the results returned by previous calls to ReadableState.read() on the results any of the reading methods (get(K), keys(),
values(), and entries()).
void remove(K key)
Changes will not be reflected in the results returned by previous calls to ReadableState.read() on the results any of the reading methods (get(K), keys(),
values(), and entries()).
ReadableState<V> get(K key)
A user is encouraged to call get for all relevant keys and call readLater()
on the results.
When read() is called, a particular state implementation is encouraged to perform
all pending reads in a single batch.
ReadableState<V> getOrDefault(K key, @Nullable V defaultValue)
A user is encouraged to call get for all relevant keys and call readLater()
on the results.
When read() is called, a particular state implementation is encouraged to perform
all pending reads in a single batch.
ReadableState<java.lang.Iterable<K>> keys()
Iterable over the keys contained in this map.ReadableState<java.lang.Iterable<V>> values()
Iterable over the values contained in this map.ReadableState<java.lang.Iterable<java.util.Map.Entry<K,V>>> entries()
Iterable over the key-value pairs contained in this map.ReadableState<java.lang.Boolean> isEmpty()
ReadableState whose ReadableState.read() method will return true if
this state is empty at the point when that ReadableState.read() call returns.