Top Description Fields Constructors Methods
groovy.lang

public Class SpreadMap

extends HashMap
Class Inheritance
Imports
org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation, java.util.HashMap, .Iterator, .List, .Map

Helper to turn a list with an even number of elements into a Map.

Field Summary

Modifier and TypeField and Description
private int
private static final long

Constructor Summary

AccessConstructor and Description
public
SpreadMap(Object[] values)

public
SpreadMap(Map<K, V> map)

public
SpreadMap(List<E>
the list to make spreadable
list
)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
object to be compared for equality with this map
that
)

Overrides java.util.AbstractMap.equals.

Implements java.util.Map.equals.

Compares the specified object with this map for equality.
public boolean
public int
hashCode()

Overrides java.util.AbstractMap.hashCode.

Implements java.util.Map.hashCode.

Returns the hash code value for this map.
public Object
put(Object
key with which the specified value is to be associated
key
,
Object
value to be associated with the specified key
value
)

Overrides java.util.HashMap.put.

Implements java.util.Map.put.

Associates the specified value with the specified key in this map.
public void
putAll(Map<K, V>
mappings to be stored in this map
t
)

Overrides java.util.HashMap.putAll.

Implements java.util.Map.putAll.

Copies all of the mappings from the specified map to this map.
public Object
remove(Object
key whose mapping is to be removed from the map
key
)

Overrides java.util.HashMap.remove.

Implements java.util.Map.remove.

Removes the mapping for the specified key from this map if present.
public String

Returns:

the string expression of this
toString
()

Overrides java.util.AbstractMap.toString.

Returns a string representation of this map.
Inherited from java.util.HashMap:
clearclonecomputecomputeIfAbsentcomputeIfPresentcontainsKeycontainsValueentrySetforEachgetgetOrDefaultisEmptykeySetmergenewHashMapputIfAbsentremovereplacereplacereplaceAllsizevalues

Field Detail

hashCodeback to summary
private int hashCode
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.HashMap.serialVersionUID.

Constructor Detail

SpreadMapback to summary
public SpreadMap(Object[] values)
SpreadMapback to summary
public SpreadMap(Map<K, V> map)
SpreadMapback to summary
public SpreadMap(List<E> list)
Parameters
list:List<E>

the list to make spreadable

Since
1.8.0

Method Detail

equalsback to summary
public boolean equals(Object that)

Overrides java.util.AbstractMap.equals.

Implements java.util.Map.equals.

Doc from java.util.Map.equals.

Compares the specified object with this map for equality. Returns true if the given object is also a map and the two maps represent the same mappings. More formally, two maps m1 and m2 represent the same mappings if m1.entrySet().equals(m2.entrySet()). This ensures that the equals method works properly across different implementations of the Map interface.

Parameters
that:Object

object to be compared for equality with this map

Returns:boolean

true if the specified object is equal to this map

Annotations
@Override
equalsback to summary
public boolean equals(SpreadMap that)
hashCodeback to summary
public int hashCode()

Overrides java.util.AbstractMap.hashCode.

Implements java.util.Map.hashCode.

Doc from java.util.Map.hashCode.

Returns the hash code value for this map. The hash code of a map is defined to be the sum of the hash codes of each entry in the map's entrySet() view. This ensures that m1.equals(m2) implies that m1.hashCode()==m2.hashCode() for any two maps m1 and m2, as required by the general contract of Object#hashCode.

Returns:int

the hash code value for this map

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

Overrides java.util.HashMap.put.

Implements java.util.Map.put.

Doc from java.util.HashMap.put.

Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced.

Parameters
key:Object

key with which the specified value is to be associated

value:Object

value to be associated with the specified key

Returns:Object

the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key.)

putAllback to summary
public void putAll(Map<K, V> t)

Overrides java.util.HashMap.putAll.

Implements java.util.Map.putAll.

Doc from java.util.HashMap.putAll.

Copies all of the mappings from the specified map to this map. These mappings will replace any mappings that this map had for any of the keys currently in the specified map.

Parameters
t:Map<K, V>

mappings to be stored in this map

removeback to summary
public Object remove(Object key)

Overrides java.util.HashMap.remove.

Implements java.util.Map.remove.

Doc from java.util.HashMap.remove.

Removes the mapping for the specified key from this map if present.

Parameters
key:Object

key whose mapping is to be removed from the map

Returns:Object

the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key.)

toStringback to summary
public String toString()

Overrides java.util.AbstractMap.toString.

Doc from java.util.AbstractMap.toString.

Returns a string representation of this map. The string representation consists of a list of key-value mappings in the order returned by the map's entrySet view's iterator, enclosed in braces ("{}"). Adjacent mappings are separated by the characters ", " (comma and space). Each key-value mapping is rendered as the key followed by an equals sign ("=") followed by the associated value. Keys and values are converted to strings as by String#valueOf(Object).

Returns:String

the string expression of this