你过去/现在误用了这个短语。您需要做的是将目标映射到源参数。
@Mapper(uses = { MappingHelper.class })
public interface MyMapper {
@Mappings({
@Mapping(target = "transaction.process.details", source = "request"),
//more mappings
})
Response requestToResponse(Request request);
}
然后,MapStruct应该创建中介方法并使用
MappingHelper
并调用
mapDetails
方法如果有多个方法从
Request
到任何类型
details
here
在文档中)。
它看起来像:
public class MappingHelper {
@Named("mapDetails") // or the better type safe one with the meta annotation @Qualifier
public static String mapDetails(Request request);
}
您的映射将如下所示:
@Mapper(uses = { MappingHelper.class })
public interface MyMapper {
@Mappings({
@Mapping(target = "transaction.process.details", source = "request", qualifiedByName = "mapDetails"), //or better with the meta annotation @Qualifier qualifiedBy
//more mappings
})
Response requestToResponse(Request request);
}