mapstruct:在目标属性中使用“。” – 目前是否支持?

huangapple go评论64阅读模式
英文:

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

huangapple
  • 本文由 发表于 2020年9月17日 16:54:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/63934577.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定