Introduction to the Fluent Builder Pattern

The fluent builder pattern is one of the most useful patterns, especially when you want to build complex objects. For example, say you want to build a complex object by initiating the builder, calling the respective setters, and finally, calling the build method. Once the build method is executed, you will get the desired model/entity/pojo object back.

Email email = Email.EmailBuilder()
              .setFrom("Test@gmail.com")
              .setTo("mail@gmail.com")
              .setSubject("Test with only required Fields")
              .setContent(" Required Field Test").build();