Package org.jboss.weld.util.collections
Class ImmutableMap<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- org.jboss.weld.util.collections.AbstractImmutableMap<K,V>
-
- org.jboss.weld.util.collections.ImmutableMap<K,V>
-
- All Implemented Interfaces:
Map<K,V>
public abstract class ImmutableMap<K,V> extends AbstractImmutableMap<K,V>
Weld's immutable map implementation.- Author:
- Jozef Hartinger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ImmutableMap.Builder<K,V>
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <K,V>
ImmutableMap.Builder<K,V>builder()
Creates a new empty builder for building immutable map.static <T,K,V>
org.jboss.weld.util.collections.ImmutableMap.ImmutableMapCollector<T,K,V>collector(Function<T,K> keyMapper, Function<T,V> valueMapper)
Returns a collector that accumulates elements into an immutable map.static <K,V>
Map<K,V>copyOf(Map<K,V> map)
Creates an immutable map.static <K,V>
Map<K,V>of(K key, V value)
Creates an immutable singleton instance.-
Methods inherited from class org.jboss.weld.util.collections.AbstractImmutableMap
clear, isEmpty, put, putAll, remove
-
Methods inherited from class java.util.AbstractMap
clone, containsKey, containsValue, entrySet, equals, get, hashCode, keySet, size, toString, values
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
copyOf
public static <K,V> Map<K,V> copyOf(Map<K,V> map)
Creates an immutable map. A copy of the given map is used. As a result, it is safe to modify the source map afterwards.- Parameters:
map
- the given map- Returns:
- an immutable map
-
of
public static <K,V> Map<K,V> of(K key, V value)
Creates an immutable singleton instance.- Parameters:
key
-value
-- Returns:
-
collector
public static <T,K,V> org.jboss.weld.util.collections.ImmutableMap.ImmutableMapCollector<T,K,V> collector(Function<T,K> keyMapper, Function<T,V> valueMapper)
Returns a collector that accumulates elements into an immutable map.Duplicate mappings are not merged - the old value is replaced.
- Parameters:
keyMapper
-valueMapper
-- Returns:
- collector
-
builder
public static <K,V> ImmutableMap.Builder<K,V> builder()
Creates a new empty builder for building immutable map.- Returns:
- a new empty builder
-
-