I love project Lombok but in these days I'm reading and trying some of the new features of java 14.
Inside the new capability, there is the record keyword that allows creating a class with already built-in the following functionality: constructor, private final fields, accessors, equals/hashCode, getters, toString methods.
Now my question is: is better to rely on the feature of Lombok or should we start using the record functionality:
Is better to use this:
record Person (String name, String surname) {}
or that:
@AllArgsConstructor
@ToString
@EqualsAndHashCode
public class Person {
@Getter private int name;
@Getter private int surname;
}
What are the pros and cons of the both approach?
question from:https://stackoverflow.com/questions/61306802/lombok-getter-setter-vs-java-14-record