K - type of key.V - type of value.public class DefaultConsistentMap<K,V> extends Synchronous<AsyncConsistentMap<K,V>> implements ConsistentMap<K,V>
ConsistentMap.DistributedPrimitive.Status, DistributedPrimitive.TypeDEFAULT_OPERATION_TIMEOUT_MILLIS| Constructor and Description | 
|---|
DefaultConsistentMap(AsyncConsistentMap<K,V> asyncMap,
                    long operationTimeoutMillis)  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
addListener(MapEventListener<K,V> listener,
           Executor executor)
Registers the specified listener to be notified whenever the map is updated. 
 | 
void | 
addStatusChangeListener(Consumer<DistributedPrimitive.Status> listener)
Registers a listener to be called when the primitive's status changes. 
 | 
Map<K,V> | 
asJavaMap()
Returns a java.util.Map instance backed by this ConsistentMap. 
 | 
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. 
 | 
Set<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. 
 | 
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. 
 | 
Iterator<Map.Entry<K,Versioned<V>>> | 
iterator()  | 
Set<K> | 
keySet()
Returns a Set view of the keys contained in this map. 
 | 
Versioned<V> | 
put(K key,
   V value)
Associates the specified value with the specified key in this map (optional operation). 
 | 
Versioned<V> | 
putAndGet(K key,
         V value)
Associates the specified value with the specified key in this map (optional operation). 
 | 
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> | 
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(MapEventListener<K,V> listener)
Unregisters the specified listener such that it will no longer
 receive map change notifications. 
 | 
void | 
removeStatusChangeListener(Consumer<DistributedPrimitive.Status> listener)
Unregisters a previously registered listener to be called when the primitive's status changes. 
 | 
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. 
 | 
Collection<Consumer<DistributedPrimitive.Status>> | 
statusChangeListeners()
Returns the collection of status change listeners previously registered. 
 | 
String | 
toString()  | 
Collection<Versioned<V>> | 
values()
Returns the collection of values (and associated versions) contained in this map. 
 | 
destroy, name, primitiveTypeclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddListener, streamapplicationId, destroy, name, primitiveTypeforEach, spliteratorpublic DefaultConsistentMap(AsyncConsistentMap<K,V> asyncMap, long operationTimeoutMillis)
public int size()
ConsistentMapsize in interface ConsistentMap<K,V>public boolean isEmpty()
ConsistentMapisEmpty in interface ConsistentMap<K,V>public boolean containsKey(K key)
ConsistentMapcontainsKey in interface ConsistentMap<K,V>key - keypublic boolean containsValue(V value)
ConsistentMapcontainsValue in interface ConsistentMap<K,V>value - valuepublic Versioned<V> get(K key)
ConsistentMapget in interface ConsistentMap<K,V>key - the key whose associated value (and version) is to be returnedpublic Versioned<V> getOrDefault(K key, V defaultValue)
ConsistentMap
 Note: a non-null Versioned value will be returned even if the defaultValue
 is null.
getOrDefault in interface ConsistentMap<K,V>key - the key whose associated value (and version) is to be returneddefaultValue - the default value to return if the key is not setpublic Versioned<V> computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
ConsistentMapcomputeIfAbsent in interface ConsistentMap<K,V>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 detectedpublic Versioned<V> computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
ConsistentMapcomputeIfPresent in interface ConsistentMap<K,V>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 detectedpublic Versioned<V> compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
ConsistentMapcompute in interface ConsistentMap<K,V>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 detectedpublic Versioned<V> computeIf(K key, Predicate<? super V> condition, BiFunction<? super K,? super V,? extends V> remappingFunction)
ConsistentMapcomputeIf in interface ConsistentMap<K,V>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 detectedpublic Versioned<V> put(K key, V value)
ConsistentMapput in interface ConsistentMap<K,V>key - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic Versioned<V> putAndGet(K key, V value)
ConsistentMapputAndGet in interface ConsistentMap<K,V>key - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic Versioned<V> remove(K key)
ConsistentMapremove in interface ConsistentMap<K,V>key - key whose value is to be removed from the mappublic void clear()
ConsistentMapclear in interface ConsistentMap<K,V>public Set<K> keySet()
ConsistentMapkeySet in interface ConsistentMap<K,V>public Collection<Versioned<V>> values()
ConsistentMapvalues in interface ConsistentMap<K,V>public Set<Map.Entry<K,Versioned<V>>> entrySet()
ConsistentMapentrySet in interface ConsistentMap<K,V>public Versioned<V> putIfAbsent(K key, V value)
ConsistentMapputIfAbsent in interface ConsistentMap<K,V>key - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic boolean remove(K key, V value)
ConsistentMapremove in interface ConsistentMap<K,V>key - key with which the specified value is associatedvalue - value expected to be associated with the specified keypublic boolean remove(K key, long version)
ConsistentMapremove in interface ConsistentMap<K,V>key - key with which the specified version is associatedversion - version expected to be associated with the specified keypublic Versioned<V> replace(K key, V value)
ConsistentMapreplace in interface ConsistentMap<K,V>key - key with which the specified value is associatedvalue - value expected to be associated with the specified keypublic boolean replace(K key, V oldValue, V newValue)
ConsistentMapreplace in interface ConsistentMap<K,V>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 keypublic boolean replace(K key, long oldVersion, V newValue)
ConsistentMapreplace in interface ConsistentMap<K,V>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 keypublic void addListener(MapEventListener<K,V> listener, Executor executor)
ConsistentMapaddListener in interface ConsistentMap<K,V>listener - listener to notify about map eventsexecutor - executor to use for handling incoming map eventspublic void removeListener(MapEventListener<K,V> listener)
ConsistentMapremoveListener in interface ConsistentMap<K,V>listener - listener to unregisterpublic void addStatusChangeListener(Consumer<DistributedPrimitive.Status> listener)
DistributedPrimitiveaddStatusChangeListener in interface DistributedPrimitivelistener - The listener to be called when the status changes.public void removeStatusChangeListener(Consumer<DistributedPrimitive.Status> listener)
DistributedPrimitiveremoveStatusChangeListener in interface DistributedPrimitivelistener - The listener to unregisterpublic Collection<Consumer<DistributedPrimitive.Status>> statusChangeListeners()
DistributedPrimitivestatusChangeListeners in interface DistributedPrimitivepublic Map<K,V> asJavaMap()
ConsistentMapasJavaMap in interface ConsistentMap<K,V>