22 January 2019

Dozer DTO assembler (upate)

Dozer is a nice little object mapper. It moves data from one object to another.

Dozer can be used as a generic Data Transfer Object assembler. You specify your mappings in an XML file. By default it copies data to properties with the same names, unless you add specific field mappings.


Next you call dozer in your code to move your data:
public Kloon getDto (Original o) {
  return dozerMapper.map(o, Kloon.class);
Dozer can reverse map from class-b to class-a as well. There is an annotation based mapping mechanism which works well for simple cases.

MapStruct is a good annotation driven alternative.

No comments:

Post a Comment