Dozer mapper simple example

Lets see Dozer mapper simple example, where we will map a java object into another using the DozerBeanMapper class.

Dozer mapper simple example

We will have SourceBean and a DestinationBean. Both of them will have similar variables. We will use the Dozer mapper to map data from SourceBean to DestinationBean

1. SourceBean.java

2. DestinationBean.java

Mappper Test Class

So as you can see just couple of lines code ( highlighted in the code snippet above) can map one object to another.

Output

Dozer mapper simple example

Dozer mapper simple example

Please Note:
We do not need to create the Mapper object everytime we need to map something. Instead you can create a Singleton object and use it across the application.

It's only fair to share...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn