2

我想为Test该类实现 JAXB,我发现如果变量是final,是否无法注入 JAXB?XmlAdapter在这种情况下会有所帮助吗?

public class Test implements Serializable {
    private final int limit;
    private Map<String, Object> results;
    private final Sub sub;

    @XmlElementWrapper(name = "item") //tried with this also,but not successfull
    @XmlAnyElement
    private final List<Item> item; 

    public Test(final Sub sub, final List<Item> item, final int limit) {
            this(pattern, results, 0, limit, offset);
    }
}

public class Item implements Serializable {
    private Base base;// Interface

    public Item(final Base base) {
        this.base = base;
    }
}

private final List<Item> item;是迭代Item类,它也有一个接口,Base如果我想实现xmlAdapter我需要这样做吗?ItemTest

4

0 回答 0