Search code examples
dozer

referencing another field in a dozer custom field converter


I have 2 classes with this structure:

class ClassA {
  String typeA;
  List<String> valuesA;
  ... other fields go here
}

class ClassB {
  String typeB;
  List<String> valuesB;
  ... other fields go here
}

I need to map the valuesA to valuesB and in the custom coverter for this field mapping I need to access the typeA/typeB.

Something like: if typeA is "type1" then map valuesA to valuesB by some algorithm and if typeA is "type2" then map by a different algorithm the valuesA to valuesB.

Is this possible with Dozer?

Thanks!


Solution

  • I think it is possible by using the programmatic (ie in Java) custom converters of Dozer.

    See the documentation, especially the TestCustomConverter Java class for an example.