In this post under Lombok, I will explain with example the purpose of “cacheStrategy” attribute of “@EqualsAndHashCode” annotation. Just for recap, the annotation “@EqualsAndHashCode” when annotated to a POJO class, it generates “equals” and “hashCode” methods. Whenever the “hashCode” method of a POJO class is called, the hash is computed. To avoid computing of hashCode…… Continue reading Using @EqualsAndHashCode cacheStrategy example
Tag: Lombok
Using @EqualsAndHashCode doNotUseGetters attribute example
In this post under Lombok, I will explain with example the purpose of “doNotUseGetters” attribute of “@EqualsAndHashCode” annotation. In a POJO class, we usually have getter method to return a formatted value of the actual value. For example, if we have a requirement where a employee has salary information stored as decimal but if he…… Continue reading Using @EqualsAndHashCode doNotUseGetters attribute example
Using @NoArgsConstructor annotation
In this post under Lombok, I will show with example the purpose of “@NoArgsConstructor” annotation. This annotation should be applied at the class level. When applied it generates a no argument constructor. Below is an example of how to use it Person class package package15; import lombok.NoArgsConstructor; @NoArgsConstructor public class Person { private String firstName;…… Continue reading Using @NoArgsConstructor annotation
Using @EqualsAndHashCode callSuper attribute
In this post under Lombok I will explain the purpose and how to use the “@EqualsAndHashCode” annotation’s “callSuper” attribute. In my previous post under “Using @EqualsAndHashCode annotation”, I explained with example the purpose of that annotation. Just for recap when this annotation is applied at class level it will automatically generates “equals” and “hashCode” methods…… Continue reading Using @EqualsAndHashCode callSuper attribute
Using @EqualsAndHashCode.Include annotation
In this post under lombok. I will explain the purpose and how to use “@EqualsAndHashCode.Include” annotation. In previous post “Using @EqualsAndHashCode.Exclude” I introduced you to “@EqualsAndHashCode.Exclude” annotation. Using “@EqualsAndHashCode.Exclude” annotation we are telling Lombok which fields should not be considered when generating “equals” and “hashCode” method of a POJO class. Now “@EqualsAndHashCode.Include” is reverse of…… Continue reading Using @EqualsAndHashCode.Include annotation
Using @EqualsAndHashCode.Exclude annotation
In this post under lombok, I will show with example the purpose of @EqualsAndHashCode.Exclude annotation. In the previous post, I explained with example the purpose of “@EqualsAndHashCode” annotation. It generates “equals” and “hashCode” method for the “@EqualsAndHashCode” annotated class. When generating “equals” and “hashCode” method it takes into consideration all the fields of the class.…… Continue reading Using @EqualsAndHashCode.Exclude annotation
Using @EqualsAndHashCode annotation
In this post under Lombok, I will explain with example the purpose and how to use “EqualsAndHashCode” annotation. This annotation is applied at the class level only. This annotation instructs Lombok to automatically generate “equals” and “hashCode” method. When generating “equals” and “hashCode” method it considers all non-static and non-transient fields. For our example we…… Continue reading Using @EqualsAndHashCode annotation
Changing display name when printing string format of an object
In this post under Lombok, I will show with example, the purpose of “name” attribute in “ToString.Include” annotation. Whenever we use “ToString” annotation on a class, it generates the string format of an object where field name (also can be called as display name) are equal to object property name. So for example if below…… Continue reading Changing display name when printing string format of an object
Using ToString.Include annotation’s rank attribute
In this post under Lombok, I will show with example the purpose of “rank” attribute in “ToString.Include” annotation. Whenever we use “ToString” annotation on a class, it generates the string format of an object with fields displayed in the order they are declared in the class. So for example if below is the class that…… Continue reading Using ToString.Include annotation’s rank attribute
Using @ToString callSuper attribute
In this post under Lombok, I will explain the purpose of and how to use “callSuper” attribute available in “@ToString” annotation. This attribute comes into picture when we are working with hierarchy of classes. For example lets say class “Shape” is a super class and class “Square” is a subclass of “Shape” class. “Shape” and…… Continue reading Using @ToString callSuper attribute