Expected behavior
If I have 2 List mapped in a class with one of them having adder, then mapstruct should ideally make use adder for this property and setter for the other.
Actual behavior
Mapstruct is mapping both source proprties to this adder property, which is incorrect
@Value
@Builder
class RequestDto {
String name;
@Singular("addItem")
List<String> items;
List<String> moreItems;
Set<String> setItems;
}
@Value
@Builder
class RequestBean {
String name;
List<String> items;
List<String> moreItems;
Set<String> setItems;
}
@Mapper(config = CentralConfig.class)
interface RequestMapper {
RequestDto toDto(RequestBean requestBean);
}
// Generated Code
@Override
public RequestDto toDto(RequestBean requestBean) {
if ( requestBean == null ) {
return null;
}
RequestDto.RequestDtoBuilder requestDto = RequestDto.builder();
if ( prechecksSupport.isNotBlank( requestBean.getName() ) ) {
requestDto.name( requestBean.getName() );
}
if ( prechecksSupport.isNotEmpty( requestBean.getItems() ) ) {
for ( String item : requestBean.getItems() ) {
requestDto.addItem( item );
}
}
if ( prechecksSupport.isNotEmpty( requestBean.getMoreItems() ) ) {
for ( String moreItem : requestBean.getMoreItems() ) {
requestDto.addItem( moreItem );
}
}
return requestDto.build();
}
If we see here, moreItems and setItems are not mapped properly
Steps to reproduce the problem
https://github.com/altaiezior/mapstruct-issues/tree/master/issue-4038
MapStruct Version
Mapstruct 1.5.5
Expected behavior
If I have 2 List mapped in a class with one of them having adder, then mapstruct should ideally make use adder for this property and setter for the other.
Actual behavior
Mapstruct is mapping both source proprties to this adder property, which is incorrect
If we see here, moreItems and setItems are not mapped properly
Steps to reproduce the problem
https://github.com/altaiezior/mapstruct-issues/tree/master/issue-4038
MapStruct Version
Mapstruct 1.5.5