Design patterns Builder Pattern Java / Lombok


Example

import lombok.Builder;

@Builder
public class Email {

    private String to;
    private String from;
    private String subject;
    private String body;

}

Usage example:

Email.builder().to("email1@email.com")
        .from("email2@email.com")
        .subject("Email subject")
        .body("Email content")
        .build();