K - type of keyV - type of valuepublic interface AtomicMap<K,V> extends SyncPrimitive
ConsistentMap provides the same functionality as AsyncAtomicMap with
the only difference that all its methods block until the corresponding operation completes.DEFAULT_OPERATION_TIMEOUT_MILLIS| Modifier and Type | Method and Description |
|---|---|
default void |
addListener(AtomicMapEventListener<K,V> listener)
Registers the specified listener to be notified whenever the map is updated.
|
void |
addListener(AtomicMapEventListener<K,V> listener,
Executor executor)
Registers the specified listener to be notified whenever the map is updated.
|
AsyncAtomicMap<K,V> |
async()
Returns the underlying asynchronous primitive.
|
void |
clear()
Removes all of the mappings from this map (optional operation).
|
Versioned<V> |
compute(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction)
Attempts to compute a mapping for the specified key and its current mapped value (or
null if there is no current mapping).
|
Versioned<V> |
computeIf(K key,
Predicate<? super V> condition,
BiFunction<? super K,? super V,? extends V> remappingFunction)
If the value for the specified key satisfies a condition, attempts to compute a new
mapping given the key and its current mapped value.
|
Versioned<V> |
computeIfAbsent(K key,
Function<? super K,? extends V> mappingFunction)
If the specified key is not already associated with a value (or is mapped to null),
attempts to compute its value using the given mapping function and enters it into
this map unless null.
|
Versioned<V> |
computeIfPresent(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction)
If the value for the specified key is present and non-null, attempts to compute a new
mapping given the key and its current mapped value.
|
boolean |
containsKey(K key)
Returns true if this map contains a mapping for the specified key.
|
boolean |
containsValue(V value)
Returns true if this map contains the specified value.
|
DistributedSet<Map.Entry<K,Versioned<V>>> |
entrySet()
Returns the set of entries contained in this map.
|
Versioned<V> |
get(K key)
Returns the value (and version) to which the specified key is mapped, or null if this
map contains no mapping for the key.
|
Map<K,Versioned<V>> |
getAllPresent(Iterable<K> keys)
Returns a map of the values associated with the
keys in this map. |
Versioned<V> |
getOrDefault(K key,
V defaultValue)
Returns the value (and version) to which the specified key is mapped, or the provided
default value if this map contains no mapping for the key.
|
boolean |
isEmpty()
Returns true if the map is empty.
|
DistributedSet<K> |
keySet()
Returns a Set view of the keys contained in this map.
|
default Versioned<V> |
put(K key,
V value)
Associates the specified value with the specified key in this map (optional operation).
|
Versioned<V> |
put(K key,
V value,
Duration ttl)
Associates the specified value with the specified key in this map (optional operation).
|
default Versioned<V> |
putAndGet(K key,
V value)
Associates the specified value with the specified key in this map (optional operation).
|
Versioned<V> |
putAndGet(K key,
V value,
Duration ttl)
Associates the specified value with the specified key in this map (optional operation).
|
default Versioned<V> |
putIfAbsent(K key,
V value)
If the specified key is not already associated with a value
associates it with the given value and returns null, else returns the current value.
|
Versioned<V> |
putIfAbsent(K key,
V value,
Duration ttl)
If the specified key is not already associated with a value
associates it with the given value and returns null, else returns the current value.
|
Versioned<V> |
remove(K key)
Removes the mapping for a key from this map if it is present (optional operation).
|
boolean |
remove(K key,
long version)
Removes the entry for the specified key only if its current
version in the map is equal to the specified version.
|
boolean |
remove(K key,
V value)
Removes the entry for the specified key only if it is currently
mapped to the specified value.
|
void |
removeListener(AtomicMapEventListener<K,V> listener)
Unregisters the specified listener such that it will no longer
receive map change notifications.
|
boolean |
replace(K key,
long oldVersion,
V newValue)
Replaces the entry for the specified key only if it is currently mapped to the
specified version.
|
Versioned<V> |
replace(K key,
V value)
Replaces the entry for the specified key only if there is any value
which associated with specified key.
|
boolean |
replace(K key,
V oldValue,
V newValue)
Replaces the entry for the specified key only if currently mapped
to the specified value.
|
int |
size()
Returns the number of entries in the map.
|
DistributedCollection<Versioned<V>> |
values()
Returns the collection of values (and associated versions) contained in this map.
|
close, deleteaddStateChangeListener, name, protocol, removeStateChangeListener, typeint size()
boolean isEmpty()
boolean containsKey(K key)
key - keyboolean containsValue(V value)
value - valueVersioned<V> get(K key)
key - the key whose associated value (and version) is to be returnedMap<K,Versioned<V>> getAllPresent(Iterable<K> keys)
keys in this map. The returned map
will only contain entries which already exist in the map.
Note that duplicate elements in keys, as determined by Object.equals(java.lang.Object), will be
ignored.
keys - the keys whose associated values are to be returnedVersioned<V> getOrDefault(K key, V defaultValue)
Note: a non-null Versioned value will be returned even if the defaultValue
is null.
key - the key whose associated value (and version) is to be returneddefaultValue - the default value to return if the key is not setVersioned<V> computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
key - key with which the specified value is to be associatedmappingFunction - the function to compute a valueConsistentMapException.ConcurrentModification
if a concurrent modification of map is detectedVersioned<V> compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
key - key with which the specified value is to be associatedremappingFunction - the function to compute a valueConsistentMapException.ConcurrentModification
if a concurrent modification of map is detectedVersioned<V> computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
key - key with which the specified value is to be associatedremappingFunction - the function to compute a valueConsistentMapException.ConcurrentModification
if a concurrent modification of map is detectedVersioned<V> computeIf(K key, Predicate<? super V> condition, BiFunction<? super K,? super V,? extends V> remappingFunction)
key - key with which the specified value is to be associatedcondition - condition that should evaluate to true for the computation to proceedremappingFunction - the function to compute a valueConsistentMapException.ConcurrentModification if a concurrent
modification of map is detecteddefault Versioned<V> put(K key, V value)
key - key with which the specified value is to be associatedvalue - value to be associated with the specified keyVersioned<V> put(K key, V value, Duration ttl)
key - key with which the specified value is to be associatedvalue - value to be associated with the specified keyttl - the time to live after which to remove the valuedefault Versioned<V> putAndGet(K key, V value)
key - key with which the specified value is to be associatedvalue - value to be associated with the specified keyVersioned<V> putAndGet(K key, V value, Duration ttl)
key - key with which the specified value is to be associatedvalue - value to be associated with the specified keyttl - the time to live after which to remove the valueVersioned<V> remove(K key)
key - key whose value is to be removed from the mapvoid clear()
DistributedSet<K> keySet()
DistributedCollection<Versioned<V>> values()
DistributedSet<Map.Entry<K,Versioned<V>>> entrySet()
default Versioned<V> putIfAbsent(K key, V value)
key - key with which the specified value is to be associatedvalue - value to be associated with the specified keyVersioned<V> putIfAbsent(K key, V value, Duration ttl)
key - key with which the specified value is to be associatedvalue - value to be associated with the specified keyttl - the time to live after which to remove the valueboolean remove(K key, V value)
key - key with which the specified value is associatedvalue - value expected to be associated with the specified keyboolean remove(K key, long version)
key - key with which the specified version is associatedversion - version expected to be associated with the specified keyVersioned<V> replace(K key, V value)
key - key with which the specified value is associatedvalue - value expected to be associated with the specified keyboolean replace(K key, V oldValue, V newValue)
key - key with which the specified value is associatedoldValue - value expected to be associated with the specified keynewValue - value to be associated with the specified keyboolean replace(K key, long oldVersion, V newValue)
key - key key with which the specified value is associatedoldVersion - version expected to be associated with the specified keynewValue - value to be associated with the specified keydefault void addListener(AtomicMapEventListener<K,V> listener)
listener - listener to notify about map eventsvoid addListener(AtomicMapEventListener<K,V> listener, Executor executor)
listener - listener to notify about map eventsexecutor - executor to use for handling incoming map eventsvoid removeListener(AtomicMapEventListener<K,V> listener)
listener - listener to unregisterAsyncAtomicMap<K,V> async()
SyncPrimitiveasync in interface SyncPrimitiveCopyright © 2013–2018. All rights reserved.