-1

We want to map

abstract Person
    PersonRole1 extends Person
    PersonRole2 extends Person

to

abstract PersonDto
   PersonDtoRoleX extends PersonDto
   PersonDtoRoleY extends PersonDto
   PersonDtoRoleZ extends PersonDto

The mapper would get Person Type as parameter (either PersonRole1 or PersonRole2). Depending on the properties of that parameter it should decide to which Dto Type to map (one of PersonDtoRoleX , PersonDtoRoleY, PersonDtoRoleZ).

What would be the best way to structure the mapstruct mapper definition?

Alexander Mihailov
  • 1,050
  • 1
  • 12
  • 19

1 Answers1

1

MapStruct is not intended to solve all the business problems you have, so you possibly need to implement your own piece of logic in a method. MapStruct will call that method from its generated code. You might want to play around with @TargetType. See here for an example.

And you could call MapStruct generated methods from within your own logic.

Sjaak
  • 3,602
  • 17
  • 29