-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Expected behavior
The provided example should compile successfully without warnings. Also, no unused code should be generated
Actual behavior
In the code example, the AbstractBoDtoMapper is configured to cause a compile error for unmapped properties. The generated code uses the mapper for the concrete subclasses (AImplMapper and BImplMapper), which both properly map all properties, including the property "legacyMyString" which needs manual mapping. Even though everything should be correct (and indeed, the generated code works as expected, if the error is disabled), Mapstruct thinks that the property "legacyMyString" was not mapped and thus shows an error.
Additionally, if the unmapped*Policies are set to default again (e.g. by removing the lines in the @Mapper annotation), the generated AbstractBoDtoMapperImpl contains code that isn't actually used anywhere:
protected ExampleObjectBo exampleObjectDtoToExampleObjectBo(ExampleObjectDto exampleObjectDto) {
if (exampleObjectDto == null) {
return null;
} else {
ExampleObjectBo exampleObjectBo = new ExampleObjectBo();
exampleObjectBo.setExampleString(exampleObjectDto.getExampleString());
return exampleObjectBo;
}
}
protected ExampleObjectDto exampleObjectBoToExampleObjectDto(ExampleObjectBo exampleObjectBo) {
if (exampleObjectBo == null) {
return null;
} else {
ExampleObjectDto exampleObjectDto = new ExampleObjectDto();
exampleObjectDto.setExampleString(exampleObjectBo.getExampleString());
return exampleObjectDto;
}
}Since the code isn't used, it shouldn't be generated by Mapstruct
Steps to reproduce the problem
See https://github.com/peterjeschke/mapstruct-reproducer for a small example. The error is shown when compiling the project
MapStruct Version
1.5.5.Final