Description
Expected behavior
When target and source object contains maps (Map<String, ?>) with same name, then the new function "Mapping from Map to Bean" should not be used
Following Object is used with MapStruct 1.4.2.Final:
@Getter
@Builder(setterPrefix = "with")
public class DispatchServiceRequest {
private final String topic;
private final String text;
private final Map<String, Object> attachments;
private final Date timestamp;
private final UUID messageId;
private final DispatcherService dispatcherService;
private final Delay delay;
}
The corresponding Mapper that worked out of the box with MapStruct 1.4.2.Final:
@Mapper(componentModel = "spring")
public interface DispatchServiceRequestMapper {
@Mapping(target = "messageId", ignore = true)
DispatchServiceRequest mapToDispatchServiceRequest(String topic, String text, Map<String, Object> attachments, Date timestamp, DispatcherService dispatcherService, Delay delay);
}
Actual behavior
With version 1.5.x.Final i get the following errors:
Multiple markers at this line
- Can't map property "Object topic" to "String topic". Consider to declare/implement a mapping method: "String map(Object value)".
- Can't map property "Object attachments" to "Map<String,Object> attachments". Consider to declare/implement a mapping method: "Map<String,Object> map(Object value)".
- Can't map property "Object text" to "String text". Consider to declare/implement a mapping method: "String map(Object value)".
- Can't map property "Object timestamp" to "Date timestamp". Consider to declare/implement a mapping method: "Date map(Object value)".
- Can't map property "Object delay" to "Delay delay". Consider to declare/implement a mapping method: "Delay map(Object value)".
- Can't map property "Object dispatcherService" to "Dispatcher.DispatcherService dispatcherService". Consider to declare/implement a mapping method: "Dispatcher.DispatcherService map(Object value)".
It seems, that the new Feature 3.10. Mapping Map to Bean breaks the old behaviour.
When i remove the parameter Map<String, Object> attachments
from the mapper method, it will compile.
When i add for each parameter a mapping like
@Mapper(componentModel = "spring")
public interface DispatchServiceRequestMapper {
@Mapping(target = "messageId", source = "")
@Mapping(target = "text", source = "text")
@Mapping(target = "delay", source = "delay")
@Mapping(target = "topic", source = "topic")
@Mapping(target = "timestamp", source = "timestamp")
@Mapping(target = "attachments", source = "attachments")
@Mapping(target = "dispatcherService", source = "dispatcherService")
DispatchServiceRequest mapToDispatchServiceRequest(String topic, String text, Map<String, Object> attachments, Date timestamp, DispatcherService dispatcherService, Delay delay);
}
then it also works but in my opinion this is some extra boilerplate which was not necessary before.
Steps to reproduce the problem
code examples: see above
MapStruct Version
MapStruct 1.5.3.Final