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
Month: February 2026
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
Using multiple source object in expressions
In previous posts under MapStruct, I introduced you guys to expressions and then I showed how we can use a source object in an expressions. Just to be thorough, in this post under MapStruct, I will show with example that we can refer multiple source objects in an expressions. For our example, we use below…… Continue reading Using multiple source object in expressions