繁体   English   中英

具有XSI类型映射的MapStruct

[英]MapStruct with XSI Type mapping

我是新来映射struct的人。 我尝试将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()));

}}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM