Package kalix.javasdk.replicatedentity
Interface ReplicatedCounterMap<K>
- Type Parameters:
K
- The type for keys.
- All Superinterfaces:
kalix.replicatedentity.ReplicatedData
public interface ReplicatedCounterMap<K>
extends kalix.replicatedentity.ReplicatedData
A Map of counters. Uses
ReplicatedCounter
's as values.-
Method Summary
Modifier and TypeMethodDescriptionclear()
Remove all mappings from this counter map.boolean
containsKey
(K key) Check whether this counter map contains a mapping for the given key.Decrement the counter at the given key by the given amount.long
Get the counter value for the given key.Increment the counter at the given key by the given amount.boolean
isEmpty()
Check whether this counter map is empty.keySet()
Get aSet
view of the keys contained in this counter map.Remove the mapping for a key if it is present.int
size()
Get the number of key-counter mappings in this counter map.
-
Method Details
-
get
Get the counter value for the given key.- 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
-
increment
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 counteramount
- the amount to increment by- Returns:
- a new counter map with the incremented value
-
decrement
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 counteramount
- the amount to decrement by- Returns:
- a new counter map with the decremented value
-
remove
Remove the mapping for a key if it is present.- Parameters:
key
- key whose mapping is to be removed from the map- Returns:
- a new counter map with the removed mapping
-
clear
ReplicatedCounterMap<K> clear()Remove all mappings from this counter map.- Returns:
- a new empty counter map
-
size
int size()Get the number of key-counter mappings in this counter map.- Returns:
- the number of key-counter mappings in this counter map
-
isEmpty
boolean isEmpty()Check whether this counter map is empty.- Returns:
true
if this counter map contains no key-counter mappings
-
containsKey
Check whether this counter map contains a mapping for the given key.- Parameters:
key
- key whose presence in this map is to be tested- Returns:
true
if this counter map contains a mapping for the given key
-
keySet
Get aSet
view of the keys contained in this counter map.- Returns:
- the keys contained in this counter map
-