Given a generic source class with a member implementing an interface,
public interface TestInterface {}
public record TestEntity<T extends TestInterface>(T data) {}
A target class,
public record TestDto(String data) {}
And a mapper,
@Mapper
public abstract class TestMapper {
@Mapping(target = "data", source = "data") // Removing this works around the issue
public abstract TestDto map(TestEntity<?> action);
String mapToString(TestInterface rawData) {
return rawData.toString();
}
}
When compiling with Mapstruct 1.5.2, the following error occurs: TestMapper.java:[12,5] Can't map property "Object data" to "String data". Consider to declare/implement a mapping method: "String map(Object value)"..
Note that removing the explicit mapping @Mapping(target = "data", source = "data") works around the issue (Obviously not possible in more complex situations).
This used to work with Mapstruct 1.4.1.
This is the reproduction case packaged as a Maven project:
mapstruct-generic-bounds.zip
Given a generic source class with a member implementing an interface,
A target class,
And a mapper,
When compiling with Mapstruct 1.5.2, the following error occurs:
TestMapper.java:[12,5] Can't map property "Object data" to "String data". Consider to declare/implement a mapping method: "String map(Object value)"..Note that removing the explicit mapping
@Mapping(target = "data", source = "data")works around the issue (Obviously not possible in more complex situations).This used to work with Mapstruct 1.4.1.
This is the reproduction case packaged as a Maven project:
mapstruct-generic-bounds.zip