Calling mapper interface method from another mapper interface code

In this post under MapStruct, I will show with example how to call one mapper interface method from another mapper interface code. For our example I will create “Address” pojo class that will be shared by “Student” and “Person” pojo class as shown below. Address package package31; public class Address { private String addressLine1; private…… Continue reading Calling mapper interface method from another mapper interface code

BeanPostProcessor example

In this post under Spring Core, I will explain with example the purpose and how to use “BeanPostProcessor” interface. In Spring framework when a bean is created, It is first constructed by calling its constructor, then dependencies are injected and initialization logic if any is executed. It is during this initialization phase that we can…… Continue reading BeanPostProcessor example

Using @Lazy annotation with @Autowired annotation example

In this post under Spring Core, I will show with example how to use “@Lazy” annotation with “@Autowired” annotation and how it change the behavior of Spring framework. In previous post, I showed with example how to use “@Lazy” annotation with “@Component” and “@Bean” annotation and how they change the behavior of Spring framework. Just…… Continue reading Using @Lazy annotation with @Autowired annotation example

Using @Lazy annotation with @Bean and @Component example

In this post under Spring Core, I will explain with example the purpose of “@Lazy” annotation and how it reacts when used with “@Bean” and “@Component” annotation. In Spring, we can use “@Lazy” annotation for two purposes1) to instruct Spring framework to lazily create a singleton bean2) to instruct Spring framework to lazily inject a…… Continue reading Using @Lazy annotation with @Bean and @Component example

CollectionUtils select method

In this post under Apache Commons Collections, I will explain with example the purpose of “select” static method in “CollectionUtils” class. This method is basically used to filter the collection based on defined predicate. Below is an example of its usage Main class package defaultPackage; import org.apache.commons.collections4.CollectionUtils; import java.util.ArrayList; import java.util.List; public class Example17 {…… Continue reading CollectionUtils select method

Using @ObjectFactory annotation to create target objects

In this post under MapStruct, I will explain with example the purpose of “@ObjectFactory” annotation. Till now in all my previous post, I have shown you that MapStruct uses constructor and builder method to create target objects. We can also create an object using factory methods. To instruct MapStruct to stop using constructor, buider method…… Continue reading Using @ObjectFactory annotation to create target objects

Reversing an array

In this post under Apache Collections, I will explain with example how to reverse a given array. Apache Collections framework “CollectionUtils” class provide a static method named “reverseArray” which can be used to reverse an array. Below is the main class showing its usage. Main Class package defaultPackage; import org.apache.commons.collections4.CollectionUtils; import java.util.Arrays; public class Example16…… Continue reading Reversing an array

IllegalSequenceRule example

In this post under Passay, I will explain with example the purpose of “IllegalSequenceRule” class. This class is used to verify that the user given password doesn’t contain known illegal sequence of characters like “qwerty” etc. Below is the complete code showing how to use it Main class package defaultPackage; import org.passay.EnglishSequenceData; import org.passay.IllegalSequenceRule; import…… Continue reading IllegalSequenceRule example

Adding custom mapping method to Mapper interface

In this post under MapStruct, I will show with example how to add custom mapping methods if the out of the box generated mapping methods aren’t sufficient. For our example I will have the following pojo classes Person package package29; public class Person { private int id; private String name; private Address address; //Removed getter…… Continue reading Adding custom mapping method to Mapper interface