Class 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
    • 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