@SubclassMapping order

Viewed 387

First time using MapStruct (1.5.0.Beta2)

Say I have the following class hierarchy: C extends B extends A and Cdto extends Bdto extends Adto. And the following mapper:

@Mapper(componentModel = "spring", subclassExhaustiveStrategy = RUNTIME_EXCEPTION)
public interface MyMapper{
    @SubclassMapping(source = B.class, target = Bdto.class)
    @SubclassMapping(source = C.class, target = Cdto.class)
    Adto map(A source);
}

When I map a list of C objects I actually get a list of Bdtos. If however I change the ordering to:

@Mapper(componentModel = "spring", subclassExhaustiveStrategy = RUNTIME_EXCEPTION)
public interface MyMapper{
    @SubclassMapping(source = C.class, target = Cdto.class)
    @SubclassMapping(source = B.class, target = Bdto.class)
    Adto map(A source);
}

I get a list of Cdtos as expected. Is this by design? Is there any way to make it less dependent on annotation order?

1 Answers
Related