In previous post under MapStruct, I showed how to create a custom mapper method and how MapStruct framework calls it. For recap,1) sometimes we cannot depend on the mapping method created by MapStruct. So we create our own custom mapper method which takes care of mapping one object properties to another object properties.2) We instruct…… Continue reading Passing the target type to custom mapper
Implementing instance factory method using Spring annotations
In this post under Spring Core, I will show how to implement instance factory method using Spring annotations instead of using xml approach. For our example, lets create “Calculator” class with below structure, whose bean we have to create using instance factory method Calculator package core.package53; public class Calculator { public void calculate() { System.out.println(“Calculating….”);…… Continue reading Implementing instance factory method using Spring annotations
Implementing static factory method using Spring annotations
In this post under Spring Core, I will show how to implement static factory method using Spring annotations instead of using xml approach. For our example, lets create “Calculator” class with below structure, whose bean we have to create using factory method Calculator package core.package52; public class Calculator { public void calculate() { System.out.println(“Calculating….”); }…… Continue reading Implementing static factory method using Spring annotations
IllegalSequenceRule with custom character sequences example 2
In previous post under Passay, I showed one example of how to use “IllegalSequenceRule” with custom character sequences. This post is continuation of the previous post with another example. In the previous post, I used different two custom character sequences, one character sequence containing only numbers and another character sequence containing only alphabets. In this…… Continue reading IllegalSequenceRule with custom character sequences example 2
IllegalSequenceRule with custom character sequences example 1
In previous post under Passay, I showed with example the purpose of “IllegalSequenceRule”. For recap, this rule makes sure that the password doesn’t contain the given character sequence, for example “qwerty” character sequence. So if the password is “qwerty” or “sam_qwerty_@”, the validation will fail but if the password is “aabb”, the validation passes. When…… Continue reading IllegalSequenceRule with custom character sequences example 1
CollectionUtils selectRejected method
In this post under Apache Collections, I will show with example the use of “selectRejected” method. “selectRejected” is a static method available under “CollectionUtils” class. It takes two arguments1) input collection2) predicate In this method, the predicate is evaluated on each item of the collection and a new collection is returned which contains items from…… Continue reading CollectionUtils selectRejected method
Using @Lookup on method with its local and instance arguments
In my previous post under Spring Core, I have explained the use of “@Lookup” annotation and how to use it with or without its arguments. In this post, I will show with example, how we can use “@Lookup” (with or without its argument) with a method that takes a local variable and instance variable as…… Continue reading Using @Lookup on method with its local and instance arguments
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