3

I have one object with the field List<AnotherObject> and I want to map it to a second object with field List<String>. I need to map 2 objects. I can not find the way.

Situation map class One -> class Two :

public class One {
    String field11;
    List<AnotherObject> field12;
}

public class AnotherObject {
    String field31;
    String field32;
}

public class Two {
    String field21;
    List<String> field22;
}

mapperFactory.classMap(One.class, Two.class)
    .fieldAToB("field11", "field21") //ok
    .fieldAToB("field12{field31}", "field22") //KO //because this is String (end element) --- > List<String>

The real business is much bigger than the example so I rule out making a custom mapper.

Tom
  • 16,842
  • 17
  • 45
  • 54
matrezz
  • 33
  • 5

1 Answers1

4

You have to map it like this:

mapperFactory.classMap(One.class, Two.class)
    .fieldAToB("field11", "field21") //ok
    .fieldAToB("field12{field31}", "field22{}") //ok

Notice the empty braces {}