Does Project Lombok offer any benefit compared to code templates / code generation in Eclipse? Are there any downsides (apart from including the .jar)?.
Some Good Practices Lombok is just a tool to make your life easy. It does not provide any assistance or support for clean code. If clean code and design principles are not of importance (trust me it's not that bad as it sounds in most of the cases), then using Lombok to simplify development process is the best option.
Lombok is an awesome Java library. It helps to reduce the amount of 'infrastructural code'. You don't need to write constructors, getters, setters, and even builders anymore. All you have to do is to put the proper annotations and the plugin will generate everything for you.
Lombok is used to reduce boilerplate code for model/data objects, e.g., it can generate getters and setters for those object automatically by using Lombok annotations. The easiest way is to use the @Data annotation.
Project Lombok works by plugging into your build process. Then, it will auto-generate the Java bytecode into your . class files required to implement the desired behavior, based on the annotations you used.
One advantage of Lombok is that once you've annotated a class with, say, the @Data annotation, you never need to regenerate the code when you make changes. For example, if you add a new field, @Data would automatically include that field in the equals, hashCode and toString methods. You'd need to manually make that change when using Eclipse generated methods. Some of the time, you may prefer the manual control but for most cases, I expect not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With