Package groovy.lang

# Class SpreadMap

java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap
groovy.lang.SpreadMap

All Implemented Interfaces:
  `Serializable`, `Cloneable`, `Map`

public class SpreadMap extends HashMap
Helper to turn a list with an even number of elements into a Map.

See Also:
  - Serialized Form

- ## Nested Class Summary

  ## 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>`

  ## Nested classes/interfaces inherited from interface java.util.Map

  `Map.Entry<K extends Object,V extends Object>`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SpreadMap(Object[] values)`
  Creates an immutable spread map from alternating key/value entries.
  `SpreadMap(List list)`
  `SpreadMap(Map map)`
  Creates an immutable spread map from an existing map.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(SpreadMap that)`
  Compares this spread map with another spread map using Groovy equality.
  `boolean`
  `equals(Object that)`
  `int`
  `hashCode()`
  `Object`
  `put(Object key, Object value)`
  Always throws because spread maps are immutable.
  `void`
  `putAll(Map t)`
  Always throws because spread maps are immutable.
  `Object`
  `remove(Object key)`
  Always throws because spread maps are immutable.
  `String`
  `toString()`

  ### Methods inherited from class java.util.HashMap

  `clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putIfAbsent, remove, replace, replace, replaceAll, size, values`

  ### Methods inherited from class java.lang.Object

  `finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### SpreadMap

    public SpreadMap(Object[] values)
    Creates an immutable spread map from alternating key/value entries.
    Parameters:
      `values` - alternating keys and values

  - ### SpreadMap

    public SpreadMap(Map map)
    Creates an immutable spread map from an existing map.
    Parameters:
      `map` - the source map

  - ### SpreadMap

    public SpreadMap(List list)
    Parameters:
      `list` - the list to make spreadable
    Since:
      1.8.0

- ## Method Details

  - ### put

    public Object put(Object key, Object value)
    Always throws because spread maps are immutable.
    Specified by:
      `put` in interface `Map`
    Overrides:
      `put` in class `HashMap`
    Parameters:
      `key` - the key to add
      `value` - the value to add
    Returns:
      never returns normally

  - ### remove

    public Object remove(Object key)
    Always throws because spread maps are immutable.
    Specified by:
      `remove` in interface `Map`
    Overrides:
      `remove` in class `HashMap`
    Parameters:
      `key` - the key to remove
    Returns:
      never returns normally

  - ### putAll

    public void putAll(Map t)
    Always throws because spread maps are immutable.
    Specified by:
      `putAll` in interface `Map`
    Overrides:
      `putAll` in class `HashMap`
    Parameters:
      `t` - the entries to add

  - ### equals

    public boolean equals(Object that)
    Specified by:
      `equals` in interface `Map`
    Overrides:
      `equals` in class `AbstractMap`

  - ### equals

    public boolean equals(SpreadMap that)
    Compares this spread map with another spread map using Groovy equality.
    Parameters:
      `that` - the other spread map
    Returns:
      `true` if the maps are equal

  - ### hashCode

    public int hashCode()
    Specified by:
      `hashCode` in interface `Map`
    Overrides:
      `hashCode` in class `AbstractMap`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `AbstractMap`
    Returns:
      the string expression of `this`