/** * Return a {@code Map} with the specific {@code name}. All invocations of this method with the same value of {@code name} * are guaranteed to return the same {@code Map} instance. <p> */ @SuppressWarnings("unchecked") public <K, V> LocalMap<K, V> getLocalMap(String name) { return (LocalMap<K, V>) localMaps.computeIfAbsent(name, n -> new LocalMapImpl<>(n, localMaps)); }
@Override public void forEach(BiConsumer<? super K, ? super V> action) { // Cannot delegate, it needs to copy the objects to avoid modifications for (Map.Entry<K, V> entry : entrySet()) { action.accept(entry.getKey(), entry.getValue()); } }
@Override public void putAll(Map<? extends K, ? extends V> m) { // Iterate over the set to entry and call `put` on each entry to validate the types for (Entry<? extends K, ? extends V> entry : m.entrySet()) { put(entry.getKey(), entry.getValue()); } }
@Override public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) { return map.computeIfAbsent(key, typeChecked(mappingFunction)); }
@Override public V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) { return map.computeIfPresent(key, typeChecked(remappingFunction)); }
@Override public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) { return map.compute(key, typeChecked(remappingFunction)); }
@Override public void putAll(Map<? extends K, ? extends V> m) { // Iterate over the set to entry and call `put` on each entry to validate the types for (Entry<? extends K, ? extends V> entry : m.entrySet()) { put(entry.getKey(), entry.getValue()); } }
@Override public void forEach(BiConsumer<? super K, ? super V> action) { // Cannot delegate, it needs to copy the objects to avoid modifications for (Map.Entry<K, V> entry : entrySet()) { action.accept(entry.getKey(), entry.getValue()); } }
/** * Return a {@code Map} with the specific {@code name}. All invocations of this method with the same value of {@code name} * are guaranteed to return the same {@code Map} instance. <p> */ @SuppressWarnings("unchecked") public <K, V> LocalMap<K, V> getLocalMap(String name) { return (LocalMap<K, V>) localMaps.computeIfAbsent(name, n -> new LocalMapImpl<>(n, localMaps)); }
@Override public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) { return map.computeIfAbsent(key, typeChecked(mappingFunction)); }
@Override public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) { return map.compute(key, typeChecked(remappingFunction)); }
@Override public V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) { return map.computeIfPresent(key, typeChecked(remappingFunction)); }