Top Fields Constructors Methods
io.vertx.core.shareddata.impl

pack-priv Class LocalMapImpl<K, V>

extends Object
implements LocalMap<K, V>
Class Inheritance
All Implemented Interfaces
io.vertx.core.shareddata.LocalMap, java.util.Map
Imports
io.vertx.core.shareddata.LocalMap, java.util.*, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, java.util.function.BiConsumer, .BiFunction, .Function

Author
Tim Fox

Field Summary

Modifier and TypeField and Description
private final ConcurrentMap<K, V>
private final ConcurrentMap<String, LocalMap<?, ?>>
private final String

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Implements io.vertx.core.shareddata.LocalMap.clear.

Clear all entries in the map

public void
close()

Implements io.vertx.core.shareddata.LocalMap.close.

Close and release the map

public V
compute(K
key with which the specified value is to be associated
key
,
BiFunction<? super K, ? super V, ? extends V>
the function to compute a value
remappingFunction
)

Implements io.vertx.core.shareddata.LocalMap.compute.

Attempts to compute a mapping for the specified key and its current mapped value (or null if there is no current mapping).

public V
computeIfAbsent(K
key with which the specified value is to be associated
key
,
Function<? super K, ? extends V>
the function to compute a value
mappingFunction
)

Implements io.vertx.core.shareddata.LocalMap.computeIfAbsent.

If the specified key is not already associated with a value (or is mapped to null), attempts to compute its value using the given mapping function and enters it into this map unless null.

public V
computeIfPresent(K
key with which the specified value is to be associated
key
,
BiFunction<? super K, ? super V, ? extends V>
the function to compute a value
remappingFunction
)

Implements io.vertx.core.shareddata.LocalMap.computeIfPresent.

If the value for the specified key is present and non-null, attempts to compute a new mapping given the key and its current mapped value.

public boolean
containsKey(Object
key whose presence in this map is to be tested
key
)

Implements io.vertx.core.shareddata.LocalMap.containsKey.

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

public boolean
containsValue(Object
value whose presence in this map is to be tested
value
)

Implements io.vertx.core.shareddata.LocalMap.containsValue.

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

public Set<Map.Entry<K, V>>
entrySet()

Implements io.vertx.core.shareddata.LocalMap.entrySet.

Returns a Set view of the mappings contained in this map.

public void
forEach(BiConsumer<? super K, ? super V>
The action to be performed for each entry
action
)

Implements io.vertx.core.shareddata.LocalMap.forEach.

Performs the given action for each entry in this map until all entries have been processed or the action throws an exception.

public V
get(Object
the key
key
)

Implements io.vertx.core.shareddata.LocalMap.get.

Get a value from the map

public V
getOrDefault(Object
the key whose associated value is to be returned
key
,
V
the default mapping of the key
defaultValue
)

Implements io.vertx.core.shareddata.LocalMap.getOrDefault.

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

public boolean
isEmpty()

Implements io.vertx.core.shareddata.LocalMap.isEmpty.

Returns true if this map contains no key-value mappings.

public Set<K>
keySet()

Implements io.vertx.core.shareddata.LocalMap.keySet.

Returns a Set view of the keys contained in this map.

public V
merge(K
key with which the resulting value is to be associated
key
,
V
the non-null value to be merged with the existing value associated with the key or, if no existing value or a null value is associated with the key, to be associated with the key
value
,
BiFunction<? super V, ? super V, ? extends V>
the function to recompute a value if present
remappingFunction
)

Implements io.vertx.core.shareddata.LocalMap.merge.

If the specified key is not already associated with a value or is associated with null, associates it with the given non-null value.

public V
put(K
the key
key
,
V
the value
value
)

Implements io.vertx.core.shareddata.LocalMap.put.

Put an entry in the map

public void
putAll(Map<? extends K, ? extends V>
mappings to be stored in this map
m
)

Implements io.vertx.core.shareddata.LocalMap.putAll.

Copies all of the mappings from the specified map to this map.

public V
putIfAbsent(K
the key
key
,
V
the value
value
)

Implements io.vertx.core.shareddata.LocalMap.putIfAbsent.

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

public V
remove(Object
the key
key
)

Implements io.vertx.core.shareddata.LocalMap.remove.

Remove an entry from the map

public boolean
remove(Object
key with which the specified value is associated
key
,
Object
value expected to be associated with the specified key
value
)

Implements io.vertx.core.shareddata.LocalMap.remove.

Removes the entry for the specified key only if it is currently mapped to the specified value.

public boolean
removeIfPresent(K
the key
key
,
V
the value
value
)

Implements io.vertx.core.shareddata.LocalMap.removeIfPresent.

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

public boolean
replace(K
key with which the specified value is associated
key
,
V
value expected to be associated with the specified key
oldValue
,
V
value to be associated with the specified key
newValue
)

Implements io.vertx.core.shareddata.LocalMap.replace.

Replaces the entry for the specified key only if currently mapped to the specified value.

public V
replace(K
the key
key
,
V
the new value
value
)

Implements io.vertx.core.shareddata.LocalMap.replace.

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

public void
replaceAll(BiFunction<? super K, ? super V, ? extends V>
the function to apply to each entry
function
)

Implements io.vertx.core.shareddata.LocalMap.replaceAll.

Replaces each entry's value with the result of invoking the given function on that entry until all entries have been processed or the function throws an exception.

public boolean
replaceIfPresent(K
the key
key
,
V
the old value
oldValue
,
V
the new value
newValue
)

Implements io.vertx.core.shareddata.LocalMap.replaceIfPresent.

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

public int
size()

Implements io.vertx.core.shareddata.LocalMap.size.

Get the size of the map

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private BiFunction<? super K, ? super V, ? extends V>

Returns:

the composition
typeChecked
(BiFunction<? super K, ? super V, ? extends V>
the function
function
)

Composes the given bi-function (f(a,b)) with a function checking the type of the output: checkType(f(a,b)).

private Function<? super K, ? extends V>

Returns:

the composition
typeChecked
(Function<? super K, ? extends V>
the function
function
)

Composes the given function (f(a)) with a function checking the type of the output.

public Collection<V>
values()

Implements io.vertx.core.shareddata.LocalMap.values.

Returns a Collection view of the values contained in this map.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

mapback to summary
private final ConcurrentMap<K, V> map
mapsback to summary
private final ConcurrentMap<String, LocalMap<?, ?>> maps
nameback to summary
private final String name

Constructor Detail

LocalMapImplback to summary
pack-priv LocalMapImpl(String name, ConcurrentMap<String, LocalMap<?, ?>> maps)

Method Detail

clearback to summary
public void clear()

Implements io.vertx.core.shareddata.LocalMap.clear.

Doc from io.vertx.core.shareddata.LocalMap.clear.

Clear all entries in the map

Annotations
@Override
closeback to summary
public void close()

Implements io.vertx.core.shareddata.LocalMap.close.

Doc from io.vertx.core.shareddata.LocalMap.close.

Close and release the map

Annotations
@Override
computeback to summary
public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction)

Implements io.vertx.core.shareddata.LocalMap.compute.

Doc from io.vertx.core.shareddata.LocalMap.compute.

Attempts to compute a mapping for the specified key and its current mapped value (or null if there is no current mapping).

If the function returns null, the mapping is removed (or remains absent if initially absent). If the function itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged.

Parameters
key:K

key with which the specified value is to be associated

remappingFunction:BiFunction<? super K, ? super V, ? extends V>

the function to compute a value

Returns:V

the new value associated with the specified key, or null if none

Annotations
@Override
computeIfAbsentback to summary
public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction)

Implements io.vertx.core.shareddata.LocalMap.computeIfAbsent.

Doc from io.vertx.core.shareddata.LocalMap.computeIfAbsent.

If the specified key is not already associated with a value (or is mapped to null), attempts to compute its value using the given mapping function and enters it into this map unless null.

If the function returns null no mapping is recorded. If the function itself throws an (unchecked) exception, the exception is rethrown, and no mapping is recorded.

Parameters
key:K

key with which the specified value is to be associated

mappingFunction:Function<? super K, ? extends V>

the function to compute a value

Returns:V

the current (existing or computed) value associated with the specified key, or null if the computed value is null

Annotations
@Override
computeIfPresentback to summary
public V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction)

Implements io.vertx.core.shareddata.LocalMap.computeIfPresent.

Doc from io.vertx.core.shareddata.LocalMap.computeIfPresent.

If the value for the specified key is present and non-null, attempts to compute a new mapping given the key and its current mapped value.

If the function returns null, the mapping is removed. If the function itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged.

Parameters
key:K

key with which the specified value is to be associated

remappingFunction:BiFunction<? super K, ? super V, ? extends V>

the function to compute a value

Returns:V

the new value associated with the specified key, or null if none

Annotations
@Override
containsKeyback to summary
public boolean containsKey(Object key)

Implements io.vertx.core.shareddata.LocalMap.containsKey.

Doc from io.vertx.core.shareddata.LocalMap.containsKey.

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

Parameters
key:Object

key whose presence in this map is to be tested

Returns:boolean

true if this map contains a mapping for the specified key

Annotations
@Override
containsValueback to summary
public boolean containsValue(Object value)

Implements io.vertx.core.shareddata.LocalMap.containsValue.

Doc from io.vertx.core.shareddata.LocalMap.containsValue.

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

Parameters
value:Object

value whose presence in this map is to be tested

Returns:boolean

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

Annotations
@Override
entrySetback to summary
public Set<Map.Entry<K, V>> entrySet()

Implements io.vertx.core.shareddata.LocalMap.entrySet.

Doc from io.vertx.core.shareddata.LocalMap.entrySet.

Returns a Set view of the mappings contained in this map.

Unlike the default Map implementation, the set is not backed by the map. So changes made to the map are not reflected in the set. Entries added or remove to the set are not reflected to the map. In addition, the entries are not modifiable (java.util.Map.Entry#setValue(Object) is not supported).

Returns:Set<Map.Entry<K, V>>

a set view of the mappings contained in this map

Annotations
@Override
forEachback to summary
public void forEach(BiConsumer<? super K, ? super V> action)

Implements io.vertx.core.shareddata.LocalMap.forEach.

Doc from io.vertx.core.shareddata.LocalMap.forEach.

Performs the given action for each entry in this map until all entries have been processed or the action throws an exception.

Exceptions thrown by the action are relayed to the caller.

Parameters
action:BiConsumer<? super K, ? super V>

The action to be performed for each entry

Annotations
@Override
getback to summary
public V get(Object key)

Implements io.vertx.core.shareddata.LocalMap.get.

Doc from io.vertx.core.shareddata.LocalMap.get.

Get a value from the map

Parameters
key:Object

the key

Returns:V

the value, or null if none

Annotations
@Override
getOrDefaultback to summary
public V getOrDefault(Object key, V defaultValue)

Implements io.vertx.core.shareddata.LocalMap.getOrDefault.

Doc from io.vertx.core.shareddata.LocalMap.getOrDefault.

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

Parameters
key:Object

the key whose associated value is to be returned

defaultValue:V

the default mapping of the key

Returns:V

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

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Implements io.vertx.core.shareddata.LocalMap.isEmpty.

Doc from java.util.Map.isEmpty.

Returns true if this map contains no key-value mappings.

Returns:boolean

Doc from io.vertx.core.shareddata.LocalMap.isEmpty.

true if there are zero entries in the map

Annotations
@Override
keySetback to summary
public Set<K> keySet()

Implements io.vertx.core.shareddata.LocalMap.keySet.

Doc from java.util.Map.keySet.

Returns a Set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.

Returns:Set<K>

Doc from io.vertx.core.shareddata.LocalMap.keySet.

the set of keys in the map

Annotations
@Override
mergeback to summary
public V merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction)

Implements io.vertx.core.shareddata.LocalMap.merge.

Doc from io.vertx.core.shareddata.LocalMap.merge.

If the specified key is not already associated with a value or is associated with null, associates it with the given non-null value. Otherwise, replaces the associated value with the results of the given remapping function, or removes if the result is null. This method may be of use when combining multiple mapped values for a key.

Parameters
key:K

key with which the resulting value is to be associated

value:V

the non-null value to be merged with the existing value associated with the key or, if no existing value or a null value is associated with the key, to be associated with the key

remappingFunction:BiFunction<? super V, ? super V, ? extends V>

the function to recompute a value if present

Returns:V

the new value associated with the specified key, or null if no value is associated with the key

Annotations
@Override
putback to summary
public V put(K key, V value)

Implements io.vertx.core.shareddata.LocalMap.put.

Doc from io.vertx.core.shareddata.LocalMap.put.

Put an entry in the map

Parameters
key:K

the key

value:V

the value

Returns:V

return the old value, or null if none

Annotations
@Override
putAllback to summary
public void putAll(Map<? extends K, ? extends V> m)

Implements io.vertx.core.shareddata.LocalMap.putAll.

Doc from io.vertx.core.shareddata.LocalMap.putAll.

Copies all of the mappings from the specified map to this map. The effect of this call is equivalent to that of calling put(k, v) on this map once for each mapping from key k to value v in the specified map. The behavior of this operation is undefined if the specified map is modified while the operation is in progress.

Parameters
m:Map<? extends K, ? extends V>

mappings to be stored in this map

Annotations
@Override
putIfAbsentback to summary
public V putIfAbsent(K key, V value)

Implements io.vertx.core.shareddata.LocalMap.putIfAbsent.

Doc from io.vertx.core.shareddata.LocalMap.putIfAbsent.

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

Parameters
key:K

the key

value:V

the value

Returns:V

the old value or null, if none

Annotations
@Override
removeback to summary
public V remove(Object key)

Implements io.vertx.core.shareddata.LocalMap.remove.

Doc from io.vertx.core.shareddata.LocalMap.remove.

Remove an entry from the map

Parameters
key:Object

the key

Returns:V

the old value

Annotations
@Override
removeback to summary
public boolean remove(Object key, Object value)

Implements io.vertx.core.shareddata.LocalMap.remove.

Doc from io.vertx.core.shareddata.LocalMap.remove.

Removes the entry for the specified key only if it is currently mapped to the specified value.

Parameters
key:Object

key with which the specified value is associated

value:Object

value expected to be associated with the specified key

Returns:boolean

true if the value was removed

Annotations
@Override
removeIfPresentback to summary
public boolean removeIfPresent(K key, V value)

Implements io.vertx.core.shareddata.LocalMap.removeIfPresent.

Doc from io.vertx.core.shareddata.LocalMap.removeIfPresent.

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

This method is the poyglot version of remove(Object, Object).

Parameters
key:K

the key

value:V

the value

Returns:boolean

true if removed

Annotations
@Override
replaceback to summary
public boolean replace(K key, V oldValue, V newValue)

Implements io.vertx.core.shareddata.LocalMap.replace.

Doc from io.vertx.core.shareddata.LocalMap.replace.

Replaces the entry for the specified key only if currently mapped to the specified value.

Parameters
key:K

key with which the specified value is associated

oldValue:V

value expected to be associated with the specified key

newValue:V

value to be associated with the specified key

Returns:boolean

true if the value was replaced

Annotations
@Override
replaceback to summary
public V replace(K key, V value)

Implements io.vertx.core.shareddata.LocalMap.replace.

Doc from io.vertx.core.shareddata.LocalMap.replace.

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

Parameters
key:K

the key

value:V

the new value

Returns:V

the old value

Annotations
@Override
replaceAllback to summary
public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function)

Implements io.vertx.core.shareddata.LocalMap.replaceAll.

Doc from io.vertx.core.shareddata.LocalMap.replaceAll.

Replaces each entry's value with the result of invoking the given function on that entry until all entries have been processed or the function throws an exception. Exceptions thrown by the function are relayed to the caller.

Parameters
function:BiFunction<? super K, ? super V, ? extends V>

the function to apply to each entry

Annotations
@Override
replaceIfPresentback to summary
public boolean replaceIfPresent(K key, V oldValue, V newValue)

Implements io.vertx.core.shareddata.LocalMap.replaceIfPresent.

Doc from io.vertx.core.shareddata.LocalMap.replaceIfPresent.

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

This method is the polyglot version of replace(Object, Object, Object).

Parameters
key:K

the key

oldValue:V

the old value

newValue:V

the new value

Returns:boolean

true if removed

Annotations
@Override
sizeback to summary
public int size()

Implements io.vertx.core.shareddata.LocalMap.size.

Doc from io.vertx.core.shareddata.LocalMap.size.

Get the size of the map

Returns:int

the number of entries in the map

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
typeCheckedback to summary
private BiFunction<? super K, ? super V, ? extends V> typeChecked(BiFunction<? super K, ? super V, ? extends V> function)

Composes the given bi-function (f(a,b)) with a function checking the type of the output: checkType(f(a,b)). So the output of the given function is checked to verify that it uses a valid type.

Parameters
function:BiFunction<? super K, ? super V, ? extends V>

the function

Returns:BiFunction<? super K, ? super V, ? extends V>

the composition

typeCheckedback to summary
private Function<? super K, ? extends V> typeChecked(Function<? super K, ? extends V> function)

Composes the given function (f(a)) with a function checking the type of the output. So the output of the given function is checked to verify that is uses a valid type.

Parameters
function:Function<? super K, ? extends V>

the function

Returns:Function<? super K, ? extends V>

the composition

valuesback to summary
public Collection<V> values()

Implements io.vertx.core.shareddata.LocalMap.values.

Doc from java.util.Map.values.

Returns a Collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The collection supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Collection.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

Returns:Collection<V>

Doc from io.vertx.core.shareddata.LocalMap.values.

the set of values in the map

Annotations
@Override