Method Summary | |
---|---|
boolean
|
any(groovy.lang.Closure closure)
Iterates over the entries of a map, and checks whether a predicate is valid for at least one entry |
java.util.Map
|
asImmutable()
A convenience method for creating an immutable map |
java.util.Map
|
asSynchronized()
A convenience method for creating a synchronized Map |
java.lang.Object
|
asType(java.lang.Class clazz)
|
java.util.Collection
|
collect(java.util.Collection collection, groovy.lang.Closure closure)
Iterates through this Map transforming each entry into a new value using the closure as a transformer, returning a list of transformed values |
java.util.List
|
collect(groovy.lang.Closure closure)
Iterates through this Map transforming each entry into a new value using the closure as a transformer, returning a list of transformed values |
java.util.Map
|
each(groovy.lang.Closure closure)
Allows a Map to be iterated through using a closure |
boolean
|
every(groovy.lang.Closure closure)
Iterates over the entries of a map, and checks whether a predicate is valid for all entries |
java.lang.Object
|
find(groovy.lang.Closure closure)
Finds the first value matching the closure condition |
java.util.Map
|
findAll(groovy.lang.Closure closure)
Finds all entries matching the closure condition |
java.lang.Object
|
get(java.lang.Object key, java.lang.Object defaultValue)
Looks up an item in a Map for the given key and returns the value - unless there is no entry for the given key in which case add the default value to the map and return that |
java.lang.Object
|
getAt(java.lang.Object key)
Support the subscript operator for a List |
java.util.Map
|
groupBy(groovy.lang.Closure closure)
Groups all map members into groups determined by the supplied mapping closure |
java.util.Map
|
plus(java.util.Map right)
Returns a new Map containg all entries from left and right , giving precedence to right
|
java.lang.Object
|
putAt(java.lang.Object key, java.lang.Object value)
A helper method to allow lists to work with subscript operators |
groovy.lang.SpreadMap
|
spread()
|
java.util.Map
|
subMap(java.util.Collection keys)
Creates a sub-Map containing the given keys |
java.lang.String
|
toMapString()
Returns the string representation of the given map with bracket boundaries |
groovy.lang.SpreadMap
|
toSpreadMap()
Returns the converted SpreadLMap of the given self
|
java.lang.String
|
toString()
Returns the string representation of the given map with bracket boundaries |
Method Detail |
---|
public boolean any(groovy.lang.Closure closure)
closure
- the closure predicate used for matching.
public java.util.Map asImmutable()
public java.util.Map asSynchronized()
public java.lang.Object asType(java.lang.Class clazz)
public java.util.Collection collect(java.util.Collection collection, groovy.lang.Closure closure)
collection
- the Collection to which the mapped values are added.
closure
- the closure used for mapping, which can be with one(Map.Entry) or two(key, value) parameters.
public java.util.List collect(groovy.lang.Closure closure)
closure
- the closure used to map each element of the collection.
public java.util.Map each(groovy.lang.Closure closure)
closure
- the closure applied on each entry of the map.
public boolean every(groovy.lang.Closure closure)
closure
- the closure predicate used for matching.
public java.lang.Object find(groovy.lang.Closure closure)
closure
- a closure condition.
public java.util.Map findAll(groovy.lang.Closure closure)
closure
- a closure condition applying on the entries.
public java.lang.Object get(java.lang.Object key, java.lang.Object defaultValue)
key
- the key to lookup the value of.
defaultValue
- the value to return and add to the map for this key if there is no entry for the given key.
public java.lang.Object getAt(java.lang.Object key)
key
- an Object as a key for the map.
public java.util.Map groupBy(groovy.lang.Closure closure)
closure
- a closure mapping entries on keys.
public java.util.Map plus(java.util.Map right)
left
and right
, giving precedence to right
. Equivalent to Map m = new HashMap(); m.putAll(left); m.putAll(right); return m;
right
- a Map.
public java.lang.Object putAt(java.lang.Object key, java.lang.Object value)
key
- an Object as a key for the map.
value
- the value to put into the map.
public groovy.lang.SpreadMap spread()
public java.util.Map subMap(java.util.Collection keys)
keys
- a Collection of keys.
public java.lang.String toMapString()
public groovy.lang.SpreadMap toSpreadMap()
SpreadLMap
of the given self
. For examples, if there is defined a function like as , then all of the following three have the same meaning.def fn(a, b, c, d) { return a + b + c + d }
println fn(a:1, [b:2, c:3].toSpreadMap(), d:4) println fn(a:1, *:[b:2, c:3], d:4) println fn(a:1, b:2, c:3, d:4)
public java.lang.String toString()