History

Some time ago I was gifted with the task of helping someone convert some old ASP forms to JSP using Spring MVC. In the midst of this task, I found that a great deal of the time taken converting these simple forms- most of which merely displayed their results on a print friendly screen- was taken up with writing validation code. "What if," says I, "there was a way to simply tag each field with how it should be validated? Java has those fancy annotation things now..."

I then proceeded to do what any self respecting coder would do, which was to spend several weeks automating a task that probably would've taken a fraction of the time to do manually. The end result was somewhat cumbersome- effectively all it did was iterate over the getter methods of a class looking for one of a set of annotations and call the appropriate validator methods in one big, ugly if statement. However, it worked, and all our most common validation conditions could now be applied as annotations, resulting in much time saved in the long run. However, on the next project we used it on it started to show some limitations- because all the validators were built in, and there was no way to define new ones without coding them into the validator framework, we still wound up writing a lot of separate validation code. I played with a few different ideas to try and make it more flexible, but higher priorities intervened.

Some months later I was lying in bed pondering life, the universe and everything, and it occurred to me that annotations could themselves be annotated, and that those annotations could be read using reflection. If an annotation had an annotation telling it to use a particular class and method to perform an action on the object it was annotating...

Leaping from the bed with a mad gleam in my eye, I began to code. This project is the end result of that mad gleam. I hope you find it useful!