Groovy Documentation

org.linkedin.groovy.util.collections
[Groovy] Class GroovyCollectionsUtils

java.lang.Object
  org.linkedin.util.collections.CollectionsUtils
      org.linkedin.groovy.util.collections.GroovyCollectionsUtils

class GroovyCollectionsUtils
extends CollectionsUtils

Authors:
ypujante@linkedin.com


Method Summary
static java.util.Map collectKey(java.util.Map srcMap, java.util.Map destMap, groovy.lang.Closure closure)

Iterate over every element in source map and store the result of closure(k,v) in the destination map under the same key.

static boolean compareContent(java.util.Collection c1, java.util.Collection c2)

More generic call which compares the content of 2 collections: it will only compare the content

static boolean compareIgnoreType(java.util.Map map1, java.util.Map map2)

The main issue when comparing 2 maps is that if the type of the map is different then the 2 maps are different even if their content is the same... this method simply compares the content of the maps.

static boolean compareIgnoreType(java.util.List list1, java.util.List list2)

The main issue when comparing 2 lists is that if the type of the list is different then the 2 lists are different even if their content is the same... this method simply compares the content of the lists

static boolean compareIgnoreType(java.util.Set set1, java.util.Set set2)

The main issue when comparing 2 sets is that if the type of the list is different then the 2 sets are different even if their content is the same... this method simply compares the content of the sets

static boolean compareIgnoreType(java.util.Collection c1, java.util.Collection c2)

The main issue when comparing 2 collections is that if the type of the collection is different then the 2 collections are different even if their content is the same... this method simply compares the content of the collections

static boolean compareIgnoreType(java.lang.Object o1, java.lang.Object o2)

This method is being used for recursivity purposes

static java.util.Map flatten(java.util.Map map)

Flattens the map.

static java.util.Map flatten(java.util.Map srcMap, java.util.Map destMap)

Same as flatten(Map) but use destMap for the result

static java.util.Map toMapKey(java.lang.Object c, groovy.lang.Closure closure)

Generates a map where the key is each element of the 'collection' c provided and the value is closure(value).

static java.util.Map toMapValue(java.lang.Object c, groovy.lang.Closure closure)

Generates a map where the value is each element of the 'collection' c provided and the key is closure(value).

 

Method Detail

collectKey

static java.util.Map collectKey(java.util.Map srcMap, java.util.Map destMap, groovy.lang.Closure closure)
Iterate over every element in source map and store the result of closure(k,v) in the destination map under the same key.
Returns:
destMap


compareContent

static boolean compareContent(java.util.Collection c1, java.util.Collection c2)
More generic call which compares the content of 2 collections: it will only compare the content


compareIgnoreType

static boolean compareIgnoreType(java.util.Map map1, java.util.Map map2)
The main issue when comparing 2 maps is that if the type of the map is different then the 2 maps are different even if their content is the same... this method simply compares the content of the maps.


compareIgnoreType

static boolean compareIgnoreType(java.util.List list1, java.util.List list2)
The main issue when comparing 2 lists is that if the type of the list is different then the 2 lists are different even if their content is the same... this method simply compares the content of the lists


compareIgnoreType

static boolean compareIgnoreType(java.util.Set set1, java.util.Set set2)
The main issue when comparing 2 sets is that if the type of the list is different then the 2 sets are different even if their content is the same... this method simply compares the content of the sets


compareIgnoreType

static boolean compareIgnoreType(java.util.Collection c1, java.util.Collection c2)
The main issue when comparing 2 collections is that if the type of the collection is different then the 2 collections are different even if their content is the same... this method simply compares the content of the collections


compareIgnoreType

static boolean compareIgnoreType(java.lang.Object o1, java.lang.Object o2)
This method is being used for recursivity purposes


flatten

static java.util.Map flatten(java.util.Map map)
Flattens the map. Ex: [a: 1, b: [1,2], c: [d: 1]] returns a map: [a: 1, 'b[0]': 1, 'b[1]': 2, 'c.d': 1]
Returns:
a new map


flatten

static java.util.Map flatten(java.util.Map srcMap, java.util.Map destMap)
Same as flatten(Map) but use destMap for the result
Returns:
destMap


toMapKey

static java.util.Map toMapKey(java.lang.Object c, groovy.lang.Closure closure)
Generates a map where the key is each element of the 'collection' c provided and the value is closure(value). Example:
[1:2, 2:3] == toMapKey([1,2]) { it + 1 }
Parameters:
c - only need to have an each(Closure) method


toMapValue

static java.util.Map toMapValue(java.lang.Object c, groovy.lang.Closure closure)
Generates a map where the value is each element of the 'collection' c provided and the key is closure(value). Example:
[2:1, 3:2] == toMapValue([1,2]) { it + 1 }
Parameters:
c - only need to have an each(Closure) method


 

Groovy Documentation