Package org.onosproject.store.primitives
Class DefaultAtomicCounterMap<K>
- java.lang.Object
- 
- org.onosproject.store.service.Synchronous<AsyncAtomicCounterMap<K>>
- 
- org.onosproject.store.primitives.DefaultAtomicCounterMap<K>
 
 
- 
- Type Parameters:
- K- map key type
 - All Implemented Interfaces:
- AtomicCounterMap<K>,- DistributedPrimitive
 
 public class DefaultAtomicCounterMap<K> extends Synchronous<AsyncAtomicCounterMap<K>> implements AtomicCounterMap<K> Default implementation ofAtomicCounterMap.
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.onosproject.store.service.DistributedPrimitiveDistributedPrimitive.Status, DistributedPrimitive.Type
 
- 
 - 
Field Summary- 
Fields inherited from interface org.onosproject.store.service.DistributedPrimitiveDEFAULT_OPERATION_TIMEOUT_MILLIS
 
- 
 - 
Constructor SummaryConstructors Constructor Description DefaultAtomicCounterMap(AsyncAtomicCounterMap<K> asyncCounterMap, long operationTimeoutMillis)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description longaddAndGet(K key, long delta)Adds delta to the value currently associated with key, and returns the new value.voidclear()Clears all entries from the map.longdecrementAndGet(K key)Decrements by one the value currently associated with key, and returns the new value.longget(K key)Returns the value associated with key, or zero if there is no value associated with key.longgetAndAdd(K key, long delta)Adds delta to the value currently associated with key, and returns the old value.longgetAndDecrement(K key)Decrements by one the value currently associated with key, and returns the old value.longgetAndIncrement(K key)Increments by one the value currently associated with key, and returns the old value.longincrementAndGet(K key)Increments by one the value currently associated with key, and returns the new value.booleanisEmpty()If the map is empty, returns true, otherwise false.longput(K key, long newValue)Associates ewValue with key in this map, and returns the value previously associated with key, or zero if there was no such value.longputIfAbsent(K key, long newValue)If key is not already associated with a value or if key is associated with zero, associate it with newValue.longremove(K key)Removes and returns the value associated with key.booleanremove(K key, long value)If (key, value) is currently in the map, this method removes it and returns true; otherwise, this method returns false.booleanreplace(K key, long expectedOldValue, long newValue)If (key, expectedOldValue) is currently in the map, this method replaces expectedOldValue with newValue and returns true; otherwise, this method return false.intsize()Returns the number of entries in the map.- 
Methods inherited from class org.onosproject.store.service.Synchronousdestroy, name, primitiveType
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.onosproject.store.service.AtomicCounterMapprimitiveType
 - 
Methods inherited from interface org.onosproject.store.service.DistributedPrimitiveaddStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListeners
 
- 
 
- 
- 
- 
Constructor Detail- 
DefaultAtomicCounterMappublic DefaultAtomicCounterMap(AsyncAtomicCounterMap<K> asyncCounterMap, long operationTimeoutMillis) 
 
- 
 - 
Method Detail- 
incrementAndGetpublic long incrementAndGet(K key) Description copied from interface:AtomicCounterMapIncrements by one the value currently associated with key, and returns the new value.- Specified by:
- incrementAndGetin interface- AtomicCounterMap<K>
- Parameters:
- key- key with which the specified value is to be associated
- Returns:
- incremented value
 
 - 
decrementAndGetpublic long decrementAndGet(K key) Description copied from interface:AtomicCounterMapDecrements by one the value currently associated with key, and returns the new value.- Specified by:
- decrementAndGetin interface- AtomicCounterMap<K>
- Parameters:
- key- key with which the specified value is to be associated
- Returns:
- updated value
 
 - 
getAndIncrementpublic long getAndIncrement(K key) Description copied from interface:AtomicCounterMapIncrements by one the value currently associated with key, and returns the old value.- Specified by:
- getAndIncrementin interface- AtomicCounterMap<K>
- Parameters:
- key- key with which the specified value is to be associated
- Returns:
- previous value
 
 - 
getAndDecrementpublic long getAndDecrement(K key) Description copied from interface:AtomicCounterMapDecrements by one the value currently associated with key, and returns the old value.- Specified by:
- getAndDecrementin interface- AtomicCounterMap<K>
- Parameters:
- key- key with which the specified value is to be associated
- Returns:
- previous value
 
 - 
addAndGetpublic long addAndGet(K key, long delta) Description copied from interface:AtomicCounterMapAdds delta to the value currently associated with key, and returns the new value.- Specified by:
- addAndGetin interface- AtomicCounterMap<K>
- Parameters:
- key- key with which the specified value is to be associated
- delta- the value to add
- Returns:
- updated value
 
 - 
getAndAddpublic long getAndAdd(K key, long delta) Description copied from interface:AtomicCounterMapAdds delta to the value currently associated with key, and returns the old value.- Specified by:
- getAndAddin interface- AtomicCounterMap<K>
- Parameters:
- key- key with which the specified value is to be associated
- delta- the value to add
- Returns:
- previous value
 
 - 
getpublic long get(K key) Description copied from interface:AtomicCounterMapReturns the value associated with key, or zero if there is no value associated with key.- Specified by:
- getin interface- AtomicCounterMap<K>
- Parameters:
- key- key with which the specified value is to be associated
- Returns:
- current value
 
 - 
putpublic long put(K key, long newValue) Description copied from interface:AtomicCounterMapAssociates ewValue with key in this map, and returns the value previously associated with key, or zero if there was no such value.- Specified by:
- putin interface- AtomicCounterMap<K>
- Parameters:
- key- key with which the specified value is to be associated
- newValue- the value to put
- Returns:
- previous value or zero
 
 - 
putIfAbsentpublic long putIfAbsent(K key, long newValue) Description copied from interface:AtomicCounterMapIf key is not already associated with a value or if key is associated with zero, associate it with newValue. Returns the previous value associated with key, or zero if there was no mapping for key.- Specified by:
- putIfAbsentin interface- AtomicCounterMap<K>
- Parameters:
- key- key with which the specified value is to be associated
- newValue- the value to put
- Returns:
- previous value or zero
 
 - 
replacepublic boolean replace(K key, long expectedOldValue, long newValue) Description copied from interface:AtomicCounterMapIf (key, expectedOldValue) is currently in the map, this method replaces expectedOldValue with newValue and returns true; otherwise, this method return false. If expectedOldValue is zero, this method will succeed if (key, zero) is currently in the map, or if key is not in the map at all.- Specified by:
- replacein interface- AtomicCounterMap<K>
- Parameters:
- key- key with which the specified value is to be associated
- expectedOldValue- the expected value
- newValue- the value to replace
- Returns:
- true if the value was replaced, false otherwise
 
 - 
removepublic long remove(K key) Description copied from interface:AtomicCounterMapRemoves and returns the value associated with key. If key is not in the map, this method has no effect and returns zero.- Specified by:
- removein interface- AtomicCounterMap<K>
- Parameters:
- key- key with which the specified value is to be associated
- Returns:
- the previous value associated with the specified key or null
 
 - 
removepublic boolean remove(K key, long value) Description copied from interface:AtomicCounterMapIf (key, value) is currently in the map, this method removes it and returns true; otherwise, this method returns false.- Specified by:
- removein interface- AtomicCounterMap<K>
- Parameters:
- key- key with which the specified value is to be associated
- value- the value to remove
- Returns:
- true if the value was removed, false otherwise
 
 - 
sizepublic int size() Description copied from interface:AtomicCounterMapReturns the number of entries in the map.- Specified by:
- sizein interface- AtomicCounterMap<K>
- Returns:
- the number of entries in the map, including 0values
 
 - 
isEmptypublic boolean isEmpty() Description copied from interface:AtomicCounterMapIf the map is empty, returns true, otherwise false.- Specified by:
- isEmptyin interface- AtomicCounterMap<K>
- Returns:
- true if the map is empty.
 
 - 
clearpublic void clear() Description copied from interface:AtomicCounterMapClears all entries from the map.- Specified by:
- clearin interface- AtomicCounterMap<K>
 
 
- 
 
-