re: Java Programming is 90% Easier with Project Lombok VIEW POST


Excellent post! I love Lombok and have been preaching it to all my classmates since I found it.
I want to mention one of my favorite annotations, @Accessors(chain = true). It lets you chain setter methods. It's still experimental, but it looks like it'll be moved into a stable feature soon.
Basically, it converts your setters from:

public void setAge(int Age) {
   this.age = age;


public DataExample setAge(int Age) {
    this.age = age;
    return this;

Allowing you to do something like this:

DataExample ex = new DataExample()

Now you've got a constructed DataExample with set properties. I find it makes writing unit tests that might need different properties for different tests SUPER simple to write and understand.


Doesn’t Lombok already support this kind of initialization using the builder pattern?


I had not really looked at @Builder before you mentioned it, but I think you're right that it'd be a much better thing to use for the use case I presented.

code of conduct - report abuse