Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LocalMap<K, V>

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

By default the map allows immutable keys and values. Custom keys and values should implement {@link Shareable} interface. The map returns their copies.

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.

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

Type parameters

  • K

  • V

Hierarchy

  • LocalMap

Index

Methods

clear

  • clear(): void
  • Clear all entries in the map

    Returns void

close

  • close(): void
  • Close and release the map

    Returns void

containsKey

  • containsKey(key: any): boolean
  • Returns true if this map contains a mapping for the specified key.

    Parameters

    • key: any

    Returns boolean

containsValue

  • containsValue(value: any): boolean
  • Returns @{code true} if this map maps one or more keys to the specified value.

    Parameters

    • value: any

    Returns boolean

get

  • get(key: any): V
  • Get a value from the map

    Parameters

    • key: any

    Returns V

getOrDefault

  • getOrDefault(key: any, defaultValue: V): V
  • Returns the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key.

    Parameters

    • key: any
    • defaultValue: V

    Returns V

isEmpty

  • isEmpty(): boolean
  • Returns boolean

put

  • put(key: K, value: V): V
  • Put an entry in the map

    Parameters

    • key: K
    • value: V

    Returns V

putIfAbsent

  • putIfAbsent(key: K, value: V): V
  • Put the entry only if there is no existing entry for that key

    Parameters

    • key: K
    • value: V

    Returns V

remove

  • remove(key: any): V
  • Remove an entry from the map

    Parameters

    • key: any

    Returns V

removeIfPresent

  • removeIfPresent(key: K, value: V): boolean
  • Remove the entry only if there is an entry with the specified key and value.

    This method is the poyglot version of {@link LocalMap#remove}.

    Parameters

    • key: K
    • value: V

    Returns boolean

replace

  • replace(key: K, value: V): V
  • Replace the entry only if there is an existing entry with the key

    Parameters

    • key: K
    • value: V

    Returns V

replaceIfPresent

  • replaceIfPresent(key: K, oldValue: V, newValue: V): boolean
  • Replace the entry only if there is an existing entry with the specified key and value.

    This method is the polyglot version of {@link LocalMap#replace}.

    Parameters

    • key: K
    • oldValue: V
    • newValue: V

    Returns boolean

size

  • size(): number
  • Get the size of the map

    Returns number

Generated using TypeDoc