Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MapStruct can't map fields to an interface #2098

Open
1 task done
bidorffOL opened this issue May 15, 2020 · 0 comments
Open
1 task done

MapStruct can't map fields to an interface #2098

bidorffOL opened this issue May 15, 2020 · 0 comments

Comments

@bidorffOL
Copy link

  • Is this an issue (and hence not a question)?

There are some use cases where it would be great to be able to have an interface as a result type. One of those is the usage of Immutables beans. Because of there structure, it is not recommended to inherit from beans annotated with @Value.Immutables. Meaning that inheritance in this case is handled this way:
A ---> @Value.Immutable AbstractA ---> ImmutableA
A ---> B ---> @Value.Immutable AbstractB ---> ImmutableB

A consequence of this is that if we want to use @InheritConfiguration in our mappers, we need to use A and B as result types rather than AbstractA and AbstractB (leading to mapstruct not detecting the beans to be Immutables). A nice way to solving that would be for mapstruct to be able to "replace" the result type with the type provided as @BeanMapping#resultType allowing to implement mappers like this:

@BeanMapping(resultType = ImmutableA.Builder.class)
A convert(xxx);

An example of the issue (with a branch expected-behavior describing the proposed solution) is available here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant