Interface TransactionalMap<K,​V>

  • Type Parameters:
    K - type of key.
    V - type of value.

    public interface TransactionalMap<K,​V>
    Transactional Map data structure.

    A TransactionalMap is created by invoking getTransactionalMap method. All operations performed on this map within a transaction boundary are invisible externally until the point when the transaction commits. A commit usually succeeds in the absence of conflicts.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean containsKey​(K key)
      Returns true if this map contains a mapping for the specified key.
      V get​(K key)
      Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
      V put​(K key, V value)
      Associates the specified value with the specified key in this map (optional operation).
      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.
      V remove​(K key)
      Removes the mapping for a key from this map if it is present (optional operation).
      boolean remove​(K key, V value)
      Removes the entry for the specified key only if it is currently mapped to the specified value.
      boolean replace​(K key, V oldValue, V newValue)
      Replaces the entry for the specified key only if currently mapped to the specified value.
    • Method Detail

      • get

        V get​(K key)
        Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
        Parameters:
        key - the key whose associated value is to be returned
        Returns:
        the value to which the specified key is mapped, or null if this map contains no mapping for the key
      • containsKey

        boolean containsKey​(K key)
        Returns true if this map contains a mapping for the specified key.
        Parameters:
        key - key whose presence in this map to be tested
        Returns:
        true if this map contains a mapping for the specified key
      • put

        V put​(K key,
              V value)
        Associates the specified value with the specified key in this map (optional operation). If the map previously contained a mapping for the key, the old value is replaced by the specified value.
        Parameters:
        key - key with which the specified value is to be associated
        value - value to be associated with the specified key
        Returns:
        the previous value associated with key, or null if there was no mapping for key.
      • remove

        V remove​(K key)
        Removes the mapping for a key from this map if it is present (optional operation).
        Parameters:
        key - key whose value is to be removed from the map
        Returns:
        the value to which this map previously associated the key, or null if the map contained no mapping for the key.
      • putIfAbsent

        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.
        Parameters:
        key - key with which the specified value is to be associated
        value - value to be associated with the specified key
        Returns:
        the previous value associated with the specified key or null if key does not already mapped to a value.
      • remove

        boolean remove​(K key,
                       V value)
        Removes the entry for the specified key only if it is currently mapped to the specified value.
        Parameters:
        key - key with which the specified value is associated
        value - value expected to be associated with the specified key
        Returns:
        true if the value was removed
      • replace

        boolean replace​(K key,
                        V oldValue,
                        V newValue)
        Replaces the entry for the specified key only if currently mapped to the specified value.
        Parameters:
        key - key with which the specified value is associated
        oldValue - value expected to be associated with the specified key
        newValue - value to be associated with the specified key
        Returns:
        true if the value was replaced