Using Comparable with multiple fields

In this post under Java Collections, I will show an example of how to use Comparable interface when we need to sort collections on multiple fields For our example, we will sort a collections of employee objects. I need to sort the collections of employee objects in ascending order first using there name and then…… Continue reading Using Comparable with multiple fields

Pattern matching with instanceof

Hi all, in this post under Java pattern matching section, I will introduce you to pattern matching and how to use it with instanceof operator. Please don’t confuse java pattern matching with regex pattern matching Regex pattern matching checks whether a given text matches a text pattern and may optionally extract parts of the text.…… Continue reading Pattern matching with instanceof

DictionaryRule with TernaryDictionary example

In this post under Passay, I will show with example, how to use “TernaryDictionary” with “DictionaryRule”. For recap, DictionaryRule will check whether the user inputed password matches a word amoung a dictionary of words. If it matches, the validation fails or else passes. The dictionary of words can be implemented in many ways but for…… Continue reading DictionaryRule with TernaryDictionary example

Passing context information to custom mapping method

In this post under MapStruct, I will explain with example how to pass context information to custom mapping methods. In the previous post, I have explained how to tell MapStruct which is the context information i.e., by annotating it with “@Context” annotation as shown below @Mapping(target = "addressDTO", source = "address") PersonDTO personToPersonDTO(Person person, @Context…… Continue reading Passing context information to custom mapping method

Passing context information to mapping method

In this post under MapStruct, I will show with example how to pass context information to the mapping methods. For our example, I will have “Person” entity and map it to “PersonDTO” entity. Below is the class structure of “Person” class Person package package34; public class Person { private int id; private String name; private…… Continue reading Passing context information to mapping method

CollectionUtils transform method

In this post under Apache Collections, I will show with example, how to use and purpose of “transform” static method in Apache Collections “CollectionUtils” class. The “transform” method can be used to transform each elements in a collection. The transformer logic is implemented by implementing the “Transformer” functional interface. Please note it doesn’t create a…… Continue reading CollectionUtils transform method

Ordering multiple BeanPostProcessor implementations example

In this post under Spring Core, I will show with example how to order multiple “BeanPostProcessor” interface implementations. To order multiple “BeanPostProcessor” implementations, each implementations much implement “Ordered” interface and provide order number in the interface “getOrder” method. Note: Ordering of “BeanPostProcessor” implementations only work with “@Component” annotation and not with “@Bean” annotation. For our…… Continue reading Ordering multiple BeanPostProcessor implementations example

DictionaryRule with WordListDictionary example

In this post under Passay, I will show with example what is the purpose and how to use “DictionaryRule”. DictionaryRule will check whether the user inputed password matches a word amoung a dictionary of words. If it matches, the validation fails or else passes. The dictionary of words can be implemented in many ways but…… Continue reading DictionaryRule with WordListDictionary example