Generate a builder with Lombok

Is possible to auto-generate builders for a Java class using @Builder lombok annotation. They’re really simple though and do not provide auto-filling. They just create an API to fill them with test data.

All we need is to put the annotation into a Java class

public class PersonDto {

  private long id;

  private String name;
  private int age;

  private Set<String> hobbies;


This provides the basic API to use them as follows

public class Whatever {

  public PersonDto buildPerson() {
    return PersonDto.builder().age(18)


The @Singular annotation is given to Collections and it adds a couple of methods. One to add a single Object, another to add Collections of Objects and a third one to clear all.