Grails, Technology

Groovy collectEntries to get a Map from a Collection

Dealing with collections is a part of a Developer’s daily life. However, sometimes it becomes quite cumbersome when we have to iterate through each collection every time we want a manipulated Collection. Ever thought of a groovier way to manipulate a collection and get a Map in a single line? Well, multiple iterations to convert a...

by Manali Khanna
Tag: collections
15-Jul-2015

Grails

Dealing with immutable collections in Java

Perhaps, you know it before or just skipped it after going through Java API. But I really found it very helpful at this point.   Recently, I had a requirement in an open-source project, where users can iterate through the objects saved in collections (esp. List). But the problem was, we really didn’t want users to directly or...

by Salil
Tag: collections
11-Apr-2012

Grails

Groovy: Sort list of objects on the basis of more than one field

Usually, when we deal with databases, we don't face such kind of situation because we query database to get result-set in required order. But let's say you have a List of objects that you want to sort on the basis of two fields. Let's discuss it with an example. I have a list of Tasks (with date and priority fields). I want to sort...

by Salil
Tag: collections
25-Jan-2011