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.

Your own objects can be marked as immutable by implementing the io.vertx.core.shareddata.Shareable interface.

Since the version 3.4, this class extends the interface. However some methods are only accessible in Java.

no subtypes hierarchy

Initializer
LocalMap(LocalMap<out Object,out Object> unknown)
Inherited Attributes
Attributes inherited from: Object
hash, string
Methods
clearshared default void clear()

Clear all entries in the map

closeshared default void close()

Close and release the map

containsKeyshared default Boolean containsKey(Object? key)

Returns true if this map contains a mapping for the specified key.

Parameters:
  • key

    key whose presence in this map is to be tested

containsValueshared default Boolean containsValue(Object? value)

Returns @{code true} if this map maps one or more keys to the specified value.

Parameters:
  • value

    value whose presence in this map is to be tested

getshared default V get(Object? key)

Get a value from the map

Parameters:
  • key

    the key

getOrDefaultshared default V getOrDefault(Object? key, V defaultValue)

Returns the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key.

Parameters:
  • key

    the key whose associated value is to be returned

  • defaultValue

    the default mapping of the key

isEmptyshared default Boolean isEmpty()
putshared default V put(K key, V value)

Put an entry in the map

Parameters:
  • key

    the key

  • value

    the value

putIfAbsentshared default V putIfAbsent(K key, V value)

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

Parameters:
  • key

    the key

  • value

    the value

removeshared default V remove(Object? key)

Remove an entry from the map

Parameters:
  • key

    the key

removeIfPresentshared default Boolean removeIfPresent(K key, V value)

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

This method is the poyglot version of remove.

Parameters:
  • key

    the key

  • value

    the value

replaceshared default V replace(K key, V value)

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

Parameters:
  • key

    the key

  • value

    the new value

replaceIfPresentshared default Boolean replaceIfPresent(K key, V oldValue, V newValue)

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

This method is the polyglot version of replace.

Parameters:
  • key

    the key

  • oldValue

    the old value

  • newValue

    the new value

sizeshared default Integer size()

Get the size of the map

Inherited Methods
Methods inherited from: Object
equals