Java example re-written using idiomatic Groovy