MMiriamincodegroovy.com·Sep 30, 2021 · 1 min readSmall Gem: @Delegate annotationWhile looking through some source code of the open source library groovy-wslite, I came across an annotation I had not seen before - @Delegate. This annotation adds all public instance methods of the annotated field to the present class. In the ...00
MMiriamincodegroovy.com·Sep 30, 2021 · 2 min readSmall Gem: Use MDC to add a prefix to every log statementThis one was a lifesaver. I was working on code that processes messages, and needed to add the message id to every log statement. While this sounds straightforward, in reality it wasn't. Here's a very simplified version of the code that illustrate...00
MMiriamincodegroovy.com·Feb 12, 2021 · 7 min readGroovy's MarkupBuilder MagicGroovy makes it easy to generate xml. Here's an example using MarkupBuilder: import groovy.xml.MarkupBuilder new MarkupBuilder().books { book { name('Groovy in Action, Second Edition') authors { author('Dierk König') author('...00
MMiriamincodegroovy.com·Jan 29, 2021 · 5 min readTrouble with Properties in Groovy ConstructorsI ran into some issues with groovy constructors today. The real code is rather complicated, so here's a contrived sample that illustrates the issue. Take this very simple groovy class: class Person { String firstName String lastName String ful...00