I have a map of lists that I need to marshal. I created XML adapater but I keep getting java.util.List is an interface, and JAXB can't handle interfaces.
when creating JAXB context. How should I marshal Map of Lists?
This is my code:
@XmlRootElement(name = "myClass")
public class MyClass {
@XmlJavaTypeAdapter(MapOfListsAdapter.class)
protected Map<Integer, List<Condition>> expectedResults;
I have written adapter MapOfListsAdapater for the Map:
public class MapOfListsAdapter extends XmlAdapter<List<MapOfListsEntry>, Map<Integer, List<Condition>>> {
@Override
public List<MapOfListsEntry> marshal(Map<Integer, List<Condition>> v) {...}
@Override
public Map<Integer, List<Condition>> unmarshal(List<MapOfListsEntry> v) {...}
}
MapOfListEntry has these JAXB annotations:
public class MapOfListsEntry {
@XmlAttribute
private Integer key;
@XmlElementRef
@XmlElementWrapper
private List<Condition> value;