rzwitserloot/lombok — pull request #58 by luanpotter (2014-12-08 11:42:06+00:00)
Title: Adding annotation for creating Utility Classes easily

Hello! I'd like to say first that I love your project. It is amazing what it opens up with Java, and serves mainly just to show how powerful and extensible this amazing language is.
This is a feature I am missing very much in the pack for a while now. When we make Utility Classes, i.e., classes only with static methods, we should define a private default constructor, to override the public one that is created if none is presented, and avoid misuse of the class. The best practices would even ask for it to throw and exception when called, to avoid it being used internally or via reflection.
This class level annotation creates that for you, checks if no other constructors are defined, and also makes all fields, methods and inner classes static, as well as marking the class final for documentation purposes (even though it could not be subclassed already due to lack of constructors). Simple as that.
I am attaching a pull request, but it is more of a proof of concept. I did it for javac and it works fine. I noticed that I need to add a handler for eclipse as well, which is very odd (doesn't it use javac in the end as well?), but I had no luck in making it work on eclipse (there is a similar but different API, and I can't seem to get any grasp of it). I'll add here any news on that. There is also no documentation (website and whatnot). I did create a ConfigurationKey, because I inspired in the other annotations, yet I don't quite understand what that is for, apart from being some sort of custom switch or something.
Anyway, what do you guys think of this idea? Of course the name of the annotation and other details can be easily changed, e.g., it can yield an error if you create a non-static member, instead of defaulting them.