This is excellent and nasty at the same time. These are code annotations that expand at compile time to generate boilerplate. I’ve been writing a bunch of C# lately, so my reaction is that Java just needs to modernize to include properties and using-blocks. C# is much more concise than Java in many ways.
When I’m working with Drools, I often use DRL-defined classes instead of POJOs just because the former do all of the boilerplate generation already for me.
I really like that Lombok has hooks in the main IDEs.
Originally shared by Mark Proctor
Project Lombok is increasingly looking like an interesting project.
The Annotation Processor is pretty sweet, but it doesn’t allow you to modify the provided class, only to generate other classes.
Enter Lombok. It hooks into JavaC and JDT extensions to allow AST modifications to the current class as it compiles. It works with Intellij, Eclipse and Netbeans. Further it’s GWT ready.
For those worried about being being tied into the Lombok annotations, You can DeLombok at any time, where it’ll generate the source with all the Lombok love removed.
Lombok does not have any runtime requirements, making it pretty sweet. Compared to other more intrusive frameworks that try to help writing less code.
Lombok has a number of interesting annotation to reduce boiler place code:
@Getter/@Setter speak for themselves. But @Cleanup is also interesting. I’ve attached a screenshot of how it looks. I know resource clean up has improved in java8. But @Cleanup can be used now, for those stuck on java6
I wonder if Lombok could be extended to do multi-line strings? Something like below, just without the runtime cost?