AbstractJsMap
JS: Abstract Map
Implements baseline Map
-like functionality for JavaScript-compatible map structures. This is the top-most class for all custom JS map implementations provided by Elide. Specialized sub-classes are available for maps with mutability, sorted entries, multi-value entries, and threadsafe access. Each is backed by an equivalent Java map, with JavaScript map methods mapped to equivalent Java map methods.
Mutability
By default, maps which adhere to this interface are non-mutable. BaseMutableJsMap implements the mutability methods and provides an equivalent top-abstract-base.
Sorting
Since the structure of JS-provided map classes is like a giant Russian doll toy (with all map types extending this one, and so on), it is entirely possible to represent sorted maps as regular JsMap or AbstractJsMap instances. By keeping a type which adheres to JsSortedMap, the developer knows that the map is sorted, and can rely on the internal map state reflecting that.
Concurrency
Thread-safe maps are available where the underlying Java map is thread-safe. Concurrent maps should not usually be necessary when interfacing with JS code, since JS execution is inherently single-threaded in almost all cases. If, however, you are doing work in the background (in another thread) with a map that is exposed to JavaScript, a thread safe map can make sure both views of the backing data are consistent.
Parameters
Key type for the map. Keys cannot be null
.
Value type for the map. Values can be null
.
Whether the map implementation holds a sorted representation.
Whether the map implementation is mutable.
Whether the map implementation allows multiple values per key.
Whether the map implementation is thread-safe.