In my current java project we are considering to use Lombok instead of public fields. My colleagues think, that this will bring better encapsulation.
In contrary to Why use getters and setters/accessors? , in which the benefits of hand written getters and setters are discussed, I'm challanging the fact of using auto-generated, hard-to-customize getters and setters.
Is there any benefit of using this code:
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class MyBean {
private String firstName;
private String lastName;
}
Instead of this code? (Which is easier to understand and shorter and has less dependencies?)
public class MyBean {
public String firstName;
public String lastName;
}