Package io.cloudstate.javasupport.crdt
Class PNCounterMap<K>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- io.cloudstate.javasupport.crdt.PNCounterMap<K>
-
- Type Parameters:
K- The type for keys.
- All Implemented Interfaces:
java.util.Map<K,java.lang.Long>
public final class PNCounterMap<K> extends java.util.AbstractMap<K,V> implements java.util.Map<K,java.lang.Long>
-
-
Constructor Summary
Constructors Constructor Description PNCounterMap(ORMap<K,PNCounter> ormap)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(java.lang.Object key)longdecrement(java.lang.Object key, long by)Decrement the counter at the given key by the given amount.java.util.Set<java.util.Map.Entry<K,V>>entrySet()Vget(java.lang.Object key)longgetValue(java.lang.Object key)Get the value for the given key.longincrement(java.lang.Object key, long by)Increment the counter at the given key by the given amount.java.util.Set<K>keySet()java.lang.Longput(K key, java.lang.Long value)Not supported on PNCounter, use increment/decrement instead.Vremove(java.lang.Object key)intsize()-
Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, putAll, toString, values
-
-
-
-
Method Detail
-
getValue
public long getValue(java.lang.Object key)
Get the value for the given key.This differs from
Map.get(Object)in that it returns a primitivelong, and thus avoids an allocation.- Parameters:
key- The key to get the value for.- Returns:
- The current value of the counter at that key, or zero if no counter exists for that key.
-
increment
public long increment(java.lang.Object key, long by)Increment the counter at the given key by the given amount.The counter will be created if it is not already in the map.
- Parameters:
key- The key of the counter.by- The amount to increment by.- Returns:
- The new value of the counter.
-
decrement
public long decrement(java.lang.Object key, long by)Decrement the counter at the given key by the given amount.The counter will be created if it is not already in the map.
- Parameters:
key- The key of the counter.by- The amount to decrement by.- Returns:
- The new value of the counter.
-
put
public java.lang.Long put(K key, java.lang.Long value)
Not supported on PNCounter, use increment/decrement instead.- Specified by:
putin interfacejava.util.Map<K,java.lang.Long>
-
size
public int size()
- Specified by:
sizein interfacejava.util.Map<K,V>- Overrides:
sizein classjava.util.AbstractMap<K,V>
-
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKeyin interfacejava.util.Map<K,V>- Overrides:
containsKeyin classjava.util.AbstractMap<K,V>
-
get
public V get(java.lang.Object key)
- Specified by:
getin interfacejava.util.Map<K,V>- Overrides:
getin classjava.util.AbstractMap<K,V>
-
remove
public V remove(java.lang.Object key)
- Specified by:
removein interfacejava.util.Map<K,V>- Overrides:
removein classjava.util.AbstractMap<K,V>
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Map<K,V>- Overrides:
clearin classjava.util.AbstractMap<K,V>
-
keySet
public java.util.Set<K> keySet()
- Specified by:
keySetin interfacejava.util.Map<K,V>- Overrides:
keySetin classjava.util.AbstractMap<K,V>
-
entrySet
public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
- Specified by:
entrySetin interfacejava.util.Map<K,V>- Specified by:
entrySetin classjava.util.AbstractMap<K,V>
-
-