Wednesday, 30 July 2014

How correctly deserialize generic ArrayList into object with JAXB?



I have a class



@XmlType(name = "SimpleInFilter")
@XmlAccessorType(XmlAccessType.FIELD)
public class SimpleInFilter<T> implements IObjectFilter
{
@XmlElement(name = "value")
public ArrayList<T> value;

public SimpleInFilter()
{
}
}


And in another object i have a property:



@Override
@XmlElements({
@XmlElement(name = "and", type = AndFilter.class),
@XmlElement(name = "in", type = SimpleInFilter.class)
})
public abstract List<IObjectFilter> getFilters();


I need deserialize xml value like into this class, but when i deserilize it, value always is empty list.



<in>
<value>simple</value>
<value>notsimple</value>
<value>hard</value>
</in>


I'm tried write different JavaType Adapter, but it does not helped me.


No comments:

Post a Comment