I have some service with some WebMethod that returns object of Foo class:
public class Foo {
private List<Detail> detailList;
@XmlElement(name = "detail")
@XmlElementWrapper(name = "detailList")
public List<Detail> getDetailList() {
return detailList;
}
public void setDetailList(List<Detail> value) {
this.detailList = value;
}
public Foo() {
this.detailList = new ArrayList();
}
}
This code produces proper XML like:
<detailList>
<detail>
<key></key>
<value></value>
</detail>
<detail>
<key></key>
<value></value>
</detail>
<detailList/>
After building client JAR library it works OK. But I really don't like the code I need to call to get the List:
foo.getDetailList().getDetail();
Because getDetailList() returns DetailList object. How can I have getDetailList() method returning List without any changes in above XML?