This is an issue / feature request. I hope I didn't miss this but after reading the reference a few times I didn't find anything along those lines. I do hope that I can get across the point well, but I feel like my explanation isn't that good :| Let's try anyway.
Basically, I have the following situation:
@Mapping(target = "string", source = "string")
Entity map(Dto dto, String string)
where Entity has a property String string. dto is my "primary" source for parameters (yes, "primary" is a bit vague), string is a property / mapped to a property of Entity. Nevertheless, mapstruct scans String for additional properties (even though the object itself is already mapped as a property). Moreover, generic @ObjectFactories and @BeforeMappings / @AfterMappings match both objects (which is desired in general but might not be in this case).
My suggestion: Similar to @Context, introduce a @Parameter annotation (or @Property / @Mapped), which excludes the marked argument from any consideration except as a source propery. Maybe one could even the "target" argument to directly assign the argument to a property. So, for example, the above then would be:
Entity map(Dto dto, @Property("string") String string)
I guess that #1280 and #1315 are somewhat related.
Why I don't want to "work around" with @Context: The additional arguments (the string in the above example) typically are database ids which are resolved to database entities using a generic T object(UUID id, @TargetType Class<T> clazz) method. If I used @Context I would basically need to replicate this generated mapping by hand, except I am missing a trick of @Context.
This is an issue / feature request. I hope I didn't miss this but after reading the reference a few times I didn't find anything along those lines. I do hope that I can get across the point well, but I feel like my explanation isn't that good :| Let's try anyway.
Basically, I have the following situation:
where
Entityhas a propertyString string.dtois my "primary" source for parameters (yes, "primary" is a bit vague),stringis a property / mapped to a property ofEntity. Nevertheless, mapstruct scansStringfor additional properties (even though the object itself is already mapped as a property). Moreover, generic@ObjectFactoriesand@BeforeMappings /@AfterMappings match both objects (which is desired in general but might not be in this case).My suggestion: Similar to
@Context, introduce a@Parameterannotation (or@Property/@Mapped), which excludes the marked argument from any consideration except as a source propery. Maybe one could even the "target" argument to directly assign the argument to a property. So, for example, the above then would be:I guess that #1280 and #1315 are somewhat related.
Why I don't want to "work around" with
@Context: The additional arguments (thestringin the above example) typically are database ids which are resolved to database entities using a genericT object(UUID id, @TargetType Class<T> clazz)method. If I used@ContextI would basically need to replicate this generated mapping by hand, except I am missing a trick of@Context.