Groovy Documentation

org.linkedin.glu.groovy.utils.collections
[Groovy] Class GluGroovyCollectionUtils

java.lang.Object
  org.linkedin.groovy.util.collections.GroovyCollectionsUtils
      org.linkedin.glu.groovy.utils.collections.GluGroovyCollectionUtils

class GluGroovyCollectionUtils
extends GroovyCollectionsUtils

Authors:
yan@pongasoft.com


Method Summary
static java.util.Collection paginate(java.util.Collection c, int max, int offset = 0)

Paginates a collection: return how many elements you want (which also represent the number of elements per "page" and an optional offset representing at which "page" to start

static java.util.Map subMap(java.util.Map map, java.util.Collection keys)

The issue with map.subMap(['a', 'b']) is that it will add a 'b' key if not present in original map!

static java.util.Map xorMap(java.util.Map map, java.util.Collection keys)

Similar to subMap but return a map which contains only keys NOT specified in keys

 

Method Detail

paginate

static java.util.Collection paginate(java.util.Collection c, int max, int offset = 0)
Paginates a collection: return how many elements you want (which also represent the number of elements per "page" and an optional offset representing at which "page" to start
Returns:
the paginated collection


subMap

static java.util.Map subMap(java.util.Map map, java.util.Collection keys)
The issue with map.subMap(['a', 'b']) is that it will add a 'b' key if not present in original map! The intent of this call is to fix it!
Returns:
a new map (always) containing only the keys specified (if they were present in the original map!) or null if map is null


xorMap

static java.util.Map xorMap(java.util.Map map, java.util.Collection keys)
Similar to subMap but return a map which contains only keys NOT specified in keys
Returns:
a new map (alway) containing only the keys NOT specified or null if map is null


 

Groovy Documentation