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
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
Registering init and destroy methods using @Bean annotation
In this post under Spring Core, I will explain with example how to register initialization and destroy methods for a bean. FYI, a bean initialization method is called when the bean is created and destroy method is called before bean is garbage collected. All we need to tell Spring is which are the initialization and…… Continue reading Registering init and destroy methods using @Bean annotation
Giving custom name to @Bean annotated beans
In this post under Spring Core, I will show with example how to give custom id to beans. Whenever we define a bean with @Bean annotated method, we do it as below @Bean public Bean1 bean1() { return new Bean1(); } The bean id by default will be same as method name. So in the…… Continue reading Giving custom name to @Bean annotated beans
Uncompressing a gzip file
In this post under Java, I will show with example how to uncompress a gzip format file. For decompressing a gzip file, we will use java provided “GZIPInputStream” class. Below is the main code for your reference Main class 1 package zip; 2 3 import java.io.File; 4 import java.io.FileInputStream; 5 import java.io.FileOutputStream; 6 import java.io.IOException;…… Continue reading Uncompressing a gzip file
Compressing a file in gzip format
In this post under Java, I will show with example how to compress a single file in gzip format. For compressing a file in gzip format, we will use java provided “GZIPOutputStream” class. Below is the main code for your reference Main Class 1 package zip; 2 3 import java.io.File; 4 import java.io.FileInputStream; 5 import…… Continue reading Compressing a file in gzip format