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 Type
    Method
    Description
    Remove all mappings from this counter map.
    boolean
    Check whether this counter map contains a mapping for the given key.
    decrement(K key, long amount)
    Decrement the counter at the given key by the given amount.
    long
    get(K key)
    Get the counter value for the given key.
    increment(K key, long amount)
    Increment the counter at the given key by the given amount.
    boolean
    Check whether this counter map is empty.
    Get a Set view of the keys contained in this counter map.
    remove(K key)
    Remove the mapping for a key if it is present.
    int
    Get the number of key-counter mappings in this counter map.
  • Method Details

    • get

      long get(K key)
      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

      ReplicatedCounterMap<K> increment(K key, long amount)
      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
      amount - the amount to increment by
      Returns:
      a new counter map with the incremented value
    • decrement

      ReplicatedCounterMap<K> decrement(K key, long amount)
      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
      amount - the amount to decrement by
      Returns:
      a new counter map with the decremented value
    • remove

      ReplicatedCounterMap<K> remove(K key)
      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

      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

      boolean containsKey(K key)
      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

      Set<K> keySet()
      Get a Set view of the keys contained in this counter map.
      Returns:
      the keys contained in this counter map