Reputation: 1364
I have this pojo file that consists over 50 attributes. Creating a manual builder class can be error prone activity.
Is there a easy way to generate the builder class? for e.g. If you required to generate getter setters you would normally use eclipse Source > Generate Getters and Setters
Is there a painless procedure to perform this?
Really appreciate any help..
Upvotes: 3
Views: 5341
Reputation: 51
Lombok has support for all the above requirement:
You can define all the getters and setters by adding @Data. @Builder will make the class as builder.
There are more customisation also available for these annotations, you can find in their website https://projectlombok.org/
@Builder
@Data
public class Emails {
@Builder.Default
private String type = "work";
private String value;
}
Upvotes: 0
Reputation: 331
I have just used Practical macros, within a few minutes of install from the market place, I could generate *constructors*, getters / setters, toString, hashcode and equals (basically chaining the standard eclipse commands) in a single command. Just what I was looking for and saved me loads of time. I can also see a lot more uses for it, well done to Earnst (the creator).
Upvotes: 1