Package: io.vertx.groovy.core.shareddata

## [Groovy] Class LocalMap<K, V>

- io.vertx.groovy.core.shareddata.LocalMap

- Local maps can be used to share data safely in a single Vert.x instance.

  The map only allows immutable keys and values in the map, OR certain mutable objects such as Buffer instances which will be copied when they are added to the map.

  This ensures there is no shared access to mutable state from different threads (e.g. different event loops) in the Vert.x instance, and means you don't have to protect access to that state using synchronization or locks.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `LocalMap (java.lang.Object delegate)`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `void` | `clear()` Clear all entries in the map
    `void` | `close()` Close and release the map
    `V` | `get(K key)` Get a value from the map
    `java.lang.Object` | `getDelegate()`
    `boolean` | `isEmpty()` @return Returns: true if there are zero entries in the map
    `V` | `put(K key, V value)` Put an entry in the map
    `V` | `putIfAbsent(K key, V value)` Put the entry only if there is no existing entry for that key
    `V` | `remove(K key)` Remove an entry from the map
    `boolean` | `removeIfPresent(K key, V value)` Remove the entry only if there is an entry with the specified key and value
    `V` | `replace(K key, V value)` Replace the entry only if there is an existing entry with the key
    `boolean` | `replaceIfPresent(K key, V oldValue, V newValue)` Replace the entry only if there is an existing entry with the specified key and value
    `int` | `size()` Get the size of the map

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Constructor Detail

    - #### LocalMap(java.lang.Object delegate)

  - ### Method Detail

    - #### void clear()

      Clear all entries in the map

    - #### void close()

      Close and release the map

    - #### V get(K key)

      Get a value from the map

      Returns:
        the value, or null if none
      Parameters:
        `key` - the key

    - #### java.lang.Object getDelegate()

    - #### boolean isEmpty()

      Returns:
        true if there are zero entries in the map

    - #### V put(K key, V value)

      Put an entry in the map

      Returns:
        return the old value, or null if none
      Parameters:
        `key` - the key
        `value` - the value

    - #### V putIfAbsent(K key, V value)

      Put the entry only if there is no existing entry for that key

      Returns:
        the old value or null, if none
      Parameters:
        `key` - the key
        `value` - the value

    - #### V remove(K key)

      Remove an entry from the map

      Returns:
        the old value
      Parameters:
        `key` - the key

    - #### boolean removeIfPresent(K key, V value)

      Remove the entry only if there is an entry with the specified key and value

      Returns:
        true if removed
      Parameters:
        `key` - the key
        `value` - the value

    - #### V replace(K key, V value)

      Replace the entry only if there is an existing entry with the key

      Returns:
        the old value
      Parameters:
        `key` - the key
        `value` - the new value

    - #### boolean replaceIfPresent(K key, V oldValue, V newValue)

      Replace the entry only if there is an existing entry with the specified key and value

      Returns:
        true if removed
      Parameters:
        `key` - the key
        `oldValue` - the old value
        `newValue` - the new value

    - #### int size()

      Get the size of the map

      Returns:
        the number of entries in the map