-1

I have an object which contains a List<A> person as a field. I am using mapstruct to generate the classes but unsure as to how can I convert it to List<B> person in the mapper class as they are 2 different objects.

Any help will be highly appreciated.

newLearner
  • 637
  • 1
  • 12
  • 20

1 Answers1

0

Mapstruct will automatically attempt to map them, as long as the field names are the same. If you want to influence this mapping you can define your own method that has A as an argument and B as return type.

for example:

  @Mapping(target = "fullName", source = "name")
  B mapAToB(A a);

The method name can be anything that tells you what it does.

Ben Zegveld
  • 1,186
  • 2
  • 6