mapping - MapStruct 与 XSI 类型映射
问题描述
我是地图结构的新手。我正在尝试将 JSON 转换为 XML。我的 XML 组件正在寻找 XSI 类型。我已经使用强制转换 XSI 类型对象完成了自定义映射。但是 XML 缺少 XSI 类型。在子系统中处于领先地位。
default com.test.sales.types.Order map(com.test.order.types.Order value) {
if (value != null) {
com.test.sales.types.Order mapping = null;
if (value instanceof com.test.order.types.X)
mapping = map((com.test.order.types.X) value);
else if (value instanceof com.test.order.types.Y)
mapping = map((com.test.order.types.Y) value);
return mapping;
}
return null;
};
解决方案
如果您在根元素对象上设置对象,它工作正常。
default com.test.sales.types.X mapX(com.test.order.types.Order value) {
com.test.sales.types.Order mapping =
mapping = map((com.test.order.types.X) value);
return mapping;
};
default com.test.sales.types.Y mapY(com.test.order.types.Order value) {
com.test.sales.types.Order mapping =
mapping = map((com.test.order.types.Y) value);
return mapping;
};
default com.test.sales.types.Sales map(com.test.order.types.Sales data) {
com.test.sales.types.Sales returns = new com.test.sales.types.Sales();
if (data.getOrder().getIsXObj()) {
returns.setOrder(mapX(data.getOrder()));
} 别的 {
returns.setOrder(mapY(data.getOrder()));
} }
推荐阅读
- google-sheets - 具有多组信息的条码,能够自动标记
- python - 如何获得与另一个字符串长度相同的字符串?
- javascript - Apps 脚本中的全局变量
- crash - 我的应用程序在 22 分钟后崩溃。使用 E/Media HTTPConnection:Java.net.ProtocolException
- oracle - 如何传递从多个表创建的 PL/SQL 游标记录?
- java - 使用 flatMap 创建的任意不考虑过滤器
- android - AndroidManifest.xml 错误,我该如何解决这个问题?
- php - 如何通过 CodeIgniter 4 中的事件更新值
- ios - Flutter 错误:无效的 `Podfile` 文件:没有将 nil 隐式转换为字符串
- postgresql - 使用 ON CONFLICT (Id) 从 Postgresql 中的 Json 参数批量插入/更新,但必须在函数内获取未包含在参数中的 Id 属性