Java Lists: Group by element property (as Ruby group_by method)

This is a very funny function, similar to group_by from Ruby.
It takes a collection and it transforms to a hash, having keys the property *groupBy*, and values the objects having that property.

A usage example:

collectionToHash(users, "name"); // returns a hash where the keys are the distinct user names, and the values are lists of users having that property.

Continue reading