In previous posts under Lombok, I showed you how to use “@ToString” and “@ToString.Exclude” annotations. In this post, I will show with example how to use “@ToString.Include” annotation. This annotation is inverse of “@ToString.Exclude”. This annotation is also used in conjunction with “@ToString” annotation. We also need to enable “onlyExplicitlyIncluded” attribute. This annotation is also…… Continue reading Using @ToString.Include annotation
Tag: Lombok
Using @ToString.Exclude annotation
In previous post under Lombok you learned about “@ToString” annotation. It is an annotation that when applied at the class level generates a “toString” method. The “toString” method generated by Lombok considers all the non-static fields in the class. In this post under Lombok, I will show with example how to override this default behavior.…… Continue reading Using @ToString.Exclude annotation
Using @ToString annotation
In this post under Lombok, I will show with example the purpose of @ToString annotation and how to use it. This annotation is applied at class level. When applied it instructs Lombok to consider all the non-static fields in a class and generate a “toString” function. When the output of Lombok generated “toString” function is…… Continue reading Using @ToString annotation
Using @NonNull annotation
In this post under Lombok, I will show with example the purpose and how to use @NonNull annotation. This annotation is applied at method or constructor parameter level. This annotation adds a null check which will check whether the designated parameter value is null or not. If the parameter value is null it will throw…… Continue reading Using @NonNull annotation
Overriding class level Getter and Setter annotations with method level Getter and Setter annotations
In this post under Lombok, I will show how we can override Getter and Setter annotations (applied at class level) default settings by appliying same annotations at method level. Below is the example of pojo class for your reference. 1 package package3; 2 3 import java.util.Date; 4 5 import lombok.AccessLevel; 6 import lombok.Getter; 7 import…… Continue reading Overriding class level Getter and Setter annotations with method level Getter and Setter annotations
Getter and Setter annotations with AccessLevel
In previous post under Lombok, I showed how to inform Lombok to generate getter and setter methods automatically. By default getter and setter methods generated by Lombok have public access modifier. We can change the access modifier by taking help of “AccessLevel” attribute as shown below. 1 package package2; 2 3 import lombok.AccessLevel; 4 import…… Continue reading Getter and Setter annotations with AccessLevel
Getter and Setter annotations
In this post under Lombok, I will show with example the purpose of Getter and Setter annotations. These two annotations when used instructs Lombok to generate getter and setter methods. We don’t need to use these two annotations always together. We can use the anyone of them based on our needs. These two annotations can…… Continue reading Getter and Setter annotations