英文:
mapstruct: use "." as target property - is it currently supported?
问题
我想按照以下方式使用MapStruct:
@Mapping(target = ".", source = "object1.subobject2.subobject3")
public abstract Object4 toObject(Object1 object1);
由于Object1及其subobject3具有与我的结果类型Object4相同的属性,我希望它直接作为映射目标。目前,"&"操作符是一个有效的选项吗?还是我必须声明来自"object1.subobject2.subobject3"的所有属性?
英文:
I want to use mapstruct as follows:
@Mapping(target = ".", source = "object1.subobject2.subobject3")
public abstract Object4 toObject(Object1 object1);
As Object1 resp. its subobject3 has the same properties as my resulting type Object4 i want it directly as mapping target. Is the "."-operator currently a valid option or do iy have to declare all properties from "object1.subobject2.subobject3"?
答案1
得分: 3
当前映射目标或“。”可以在Mapping#target
中从1.4开始使用。
回答此问题时,版本为1.4.0.CR1。
它应该与您在问题中编写的内容完全相同。
有关此信息的更多详细信息,请阅读将嵌套的bean属性映射到当前目标。
英文:
The current mapping target or "." can be used in the Mapping#target
starting from 1.4.
At the time of answering this question, this is version 1.4.0.CR1.
It should work exactly like you have written in your question.
More information about this can be read in Mapping nested bean properties to current target
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论