title: Mapping Hierarchy of Classes with Mapstruct
body: <p>I have a hierarchy of classes: <code>VehicleDTO</code> is a base abstract class.
  <code>CarDTO, TruckDTO, VanDTO</code> extend from it.</p>
  <p>I have the same hierarchy on the other side of a mapper:
  <code>VehicleBO &lt;- CarBO, TruckBO, VanBO</code>.</p>
  <p>I want to have all the mapping logic consolidated in one mapper. Period.</p>
  <p>I have defined mappings for common attributes, but here is when it becomes interesting, I get this exception during compilation:</p>
  <pre><code>The return type ... is an abstract class or interface.
  Provide a non abstract / non interface result type or a factory method. 
  </code></pre>
  <p>So, how do I specify a factory method, that based on a value of a particular attribute or a class of the pojo, would create a target object for me? I would appreciate a good code snippet that actually does the trick.</p>
  <p>Thanks!</p>