I have a webservice soap service that takes an object with an optional list as xml parameter:
@XmlElement(required = false)
private List<String> list;
public List<String> getList() { return list; }
Is it possible to tell JAXB to always return/use an empty collection instead of a null
list if the list tag is not provided by the client?
Or will I always have to define a lazy getter on the server side for list that should never be null (I'd prefer this to be always the case)?
public List<String> getList() {
if (list == null) {
list = new ArrayList<String>();
}
return list;
}