Using @Singular with @Builder annotation example

In this post under Lombok I will explain with example the purpose of “@Singular” annotation which is alwayse used with “@Builder” annotation. In previous post under lombok I have explained why we use “@Builder” annotation i.e., to implement builder pattern. So if have below pojo class with “@Builder” annotation at the class level Pojo class…… Continue reading Using @Singular with @Builder annotation example

Using @Builder annotation example

In this post under Lombok, I will show with example how to use “@Builder” annotation to implement Builder Pattern in our application. For our example, we use the below Person pojo class. Person class package package26; public class Person { private String name; private String city; @Override public String toString() { StringBuilder stringBuilder = new…… Continue reading Using @Builder annotation example

Using @AllArgsConstructor annotation example

In this post under Lombok, I will explain the purpose of “@AllArgsConstructor” annotation and how to use it. This annotation when added at class level, automatically creates a constructor with all the fields present in the class. If a field is annotated with “@NonNull” annotation, the automatically generated constructor code will add a null check…… Continue reading Using @AllArgsConstructor annotation example

Using @RequiredArgsConstructor and @NonNull annotation example

In this post under Lombok, I will explain with example what is the purpose of “@RequiredArgsConstructor” annotation and how to use it with “@NonNull” annotation. This annotation is applied at the class level and when applied it generates constructor with a parameter for each required fields. Note: It will also add a parameter for non-initialized…… Continue reading Using @RequiredArgsConstructor and @NonNull annotation example