groovy

Groovy - Simplest way of resolving a nested property

So let's say that in Groovy you find yourself wanting to do something like this: [ 'name', 'lastName', 'address.street'].collect { propertyToResolve -> [(propertyToResolve): user[property] } You will find that the automatic getter (using it with the map syntax or as a property doesn't change anything) won't parse the argument to resolve the property in the […]

New Grails plugin - Timestamped

A Grails plugin to inject the auto-timestamp properties using a configurable, joda-time compatible AST transform that can be used both by a project and by other plugins.

Grails - small and simple method to convert objects to JSON

I was playing around with Grails and JSON and came up with a small method to convert a given collection of objects into JSON (typically, domain class objects, but it would work with anything). It's nothing new or fancy, but maybe usefull for anybody who is starting to explore Grails JSON capabilities. For the sake […]

Grails - generic methods for equals and hashCode calculation

In modern versions of Grails, you can use the Groovy annotation EqualsAndHashCode for generating the equals and hashCode methods of your domain classes using an AST transformation, but if you are in any 1.x.x Grails version (that uses a Groovy version prior to 1.8.0), you won't be able to use this. I've seen tons of […]

Execute around pattern in Groovy

The execute around pattern seems to be a common practice in fuctional related languages (although probably Rafael Luque would claim that, as almost everything else :-D , made it first appearance in Smalltalk, and Marcin Gryszko would say that is just the old plain template method :-D ), but it's probably kind of new to […]