Taking a Break From Groovy Validators

I worked a bit on my Groovy Validator project.

I was trying to process the annotation in a class referenced by GroovyASTTransformationClass. I thought that there were a couple of ways it could be done, but none of them seemed to work. I was actually able to create the setter in the class, I inserted a static initializer that called my current annotation transformer that works at runtime, but neither seemed to work.

I plan on moving on to other things for the time being. I might ask for some help on the Groovy mailing list, but if I do, I will have to formulate a coherent request. I asked for help on the list a while back, and I think I included too much detail because I never got a response.

You’re welcome.

2015-02-23 Tweets

A Small Bit of Clojure Enlightenment

I have started looking at Clojure. I think it can handle concurrency well, I think functional programming will become more important, and I think all roads lead to Lisp.

I started out by looking at some of the short introductions and tutorials on the Clojure subreddit.

Lisp variants actually have less punctuation than other languages, yet they can still be a bit hard to get used to.

I had a bit of enlightenment about anonymous functions. I could not see where they would be used. One of the tutorials said you would use then when you need a function that you might use only once.

Then I noticed that the tutorials seemed to use them as arguments to the “collection functions”, like map, reduce, filter, remove, split-with. Those functions take a function and a collection as arguments. I noticed that those functions were a common place to use anonymous functions.

You’re welcome.

2015-02-09 Tweets

2015-01-26 Tweets

Issue With Groovy Validator

I am having some issues with the Groovy Validator project. Here is an email I sent to the Groovy user mailing list:

I am making some annotations to do validation on POGOs. The github project is here:

https://github.com/emacadie/groovy-validator

One of my annotations is @StringAnnotation, which has the properties minLength, maxLength and regEx. I also have annotations for ints, longs, floats and doubles.

I got them working with POGOs and POGOs that have the @Immutable annotation.

So far I have the annotations working for POGOs by calling a static method on a class called AnnotationProcessor, and the annotations are handled by @Immutable objects with AstImmutableConstructorTransform.

https://github.com/emacadie/groovy-validator/blob/proper_annotations/src/main/groovy/info/shelfunit/properties/annotations/AnnotationProcessor.groovy

https://github.com/emacadie/groovy-validator/blob/proper_annotations/src/main/groovy/info/shelfunit/properties/annotations/AstImmutableConstructorTransform.groovy

I decided I would like to process the individual annotations with their own processor, so I started with the @StringAnnotation.
The AST class is here:

https://github.com/emacadie/groovy-validator/blob/proper_annotations/src/main/groovy/info/shelfunit/properties/annotations/StringAnnotationTransform.groovy

There are a lot of println statements since I am trying to figure all of this stuff out.

The issue that I am having is that when I run some tests the StringAnnotationTransform does not seem to work. All the strings wind up null in my tests.
Here is the command I use:
gradle clean; gradle -Dtest.single=BookSequelTest test -info

Yet, when I try these in the Groovy console (which I run with “gradle console”) things work as expected.

Why does everything work in the console but not in tests? Any ideas?