根据Java中压缩的A类的对象的值分配A类的对象的值

时间:2018-11-16 02:32:33

标签: java object copy

说我有两个类, CompactedA A 紧凑版本

class A {
    private String id = null;
    private List<B> listB = new ArrayList<B>;
    private String name = null;
    private String age = null;
}

class CompactedA {
    private String id = null;
    private List<CompactedB> listCompactedB = new ArrayList<CompactedB>;
}

class B {
    private String bId = null;
    private String bName = null;
    private String bAge = null;
}

class CompactedB {
    private String bId = null;
}

现在我得到了一个CompactedA对象(称为ca),其名称如下:

{
    id : '001',   // Id
    [
         { bId : '001b'},
         { bId : '002b'},
         { bId : '003b'},
    ]   // listCompactedB
}

如何基于a的值新建一个对象ca

a的结果应为:

{
    id: '001',
    [
        { bId: '001b', bName: null, bAge: null},
        { bId: '002b', bName: null, bAge: null},
        { bId: '003b', bName: null, bAge: null},
    ],
    name: null,
    age: null
}

0 个答案:

没有答案