-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Labels
Milestone
Description
Use case
I want to map into a wrapper type such as
public class WithStatus<A> {
public A value;
public Status status;
}
using a mapping method such as
@Mapping(source = "result", target = "value")
@Mapping(source = "status", target = "status")
public abstract WithStatus<Boolean> fromResponse(Response response);
This does not work, because MapStruct does not seem to resolve generic parameters on result types. That is, the accessor "value" should have type "Boolean" in this context, but MapStruct complains that it has type "A".
Generated Code
I'd like the generated code to be identical to what mapping to a monomorphized class would generate, i.e.
public class WithStatusBoolean {
public Boolean value;
public Status status;
}
@Mapping(source = "result", target = "value")
@Mapping(source = "status", target = "status")
public abstract WithStatusBoolean fromResponse(Response response);
Possible workarounds
The only workaround I have found is a concrete mapped class per target type, which would be quite painful in my use case.
MapStruct Version
1.6.3, 1.5.5.final
Reactions are currently unavailable