簡體   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