public class SpreadMap
extends HashMap
Helper to turn a list with an even number of elements into a Map.
| Type Params | Return Type | Name and description |
|---|---|---|
|
public boolean |
equals(Object that)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.
|
|
public boolean |
equals(SpreadMap that)Compares this spread map with another spread map using Groovy equality. |
|
public int |
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.
|
|
public Object |
put(Object key, Object value)Always throws because spread maps are immutable. |
|
public void |
putAll(Map t)Always throws because spread maps are immutable. |
|
public Object |
remove(Object key)Always throws because spread maps are immutable. |
|
public String |
toString()
|
| Methods inherited from class | Name |
|---|---|
class HashMap |
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getClass, getOrDefault, hashCode, isEmpty, keySet, merge, notify, notifyAll, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, toString, values, wait, wait, wait |
Creates an immutable spread map from alternating key/value entries.
values - alternating keys and valuesCreates an immutable spread map from an existing map.
map - the source map
list - the list to make spreadable 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.
true. Then, it checks if the specified
object is a map whose size is identical to the size of this map; if
not, it returns false. If so, it iterates over this map's
entrySet collection, and checks that the specified map
contains each mapping that this map contains. If the specified map
fails to contain such a mapping, false is returned. If the
iteration completes, true is returned.o - object to be compared for equality with this maptrue if the specified object is equal to this mapCompares this spread map with another spread map using Groovy equality.
that - the other spread maptrue if the maps are equal 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.
entrySet(), calling
Map.Entry#hashCode on each element (entry) in the
set, and adding up the results.Always throws because spread maps are immutable.
key - the key to addvalue - the value to addAlways throws because spread maps are immutable.
t - the entries to addAlways throws because spread maps are immutable.
key - the key to remove
thisCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.