-
-
Notifications
You must be signed in to change notification settings - Fork 234
Closed
Milestone
Description
When I try to deserialize this xml, XmlMapper creates empty list of action-elements:
<widget id="4" type="Transition">
<attributes>
<event/>
<action name="a"/>
<action name="b"/>
<code/>
<guard/>
</attributes>
</widget>
But if I put the type attribute on the first position, the list contains 2 elements.
Parent class Widget:
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", defaultImpl = TransitionWidget.class)
@JsonSubTypes({
@JsonSubTypes.Type(value = StateWidget.class, name = "State"),
@JsonSubTypes.Type(value = TransitionWidget.class, name = "Transition")
})
public abstract class Widget {
private Integer id;
protected Widget(Integer id) {
this.id = id;
}
@JacksonXmlProperty(isAttribute = true)
public Integer getId() {
return id;
}
}
Child class TransitionWidget:
@JacksonXmlRootElement(localName = "widget")
public class TransitionWidget extends Widget {
private final TransitionAttributes attributes;
@JsonCreator
public TransitionWidget(@JsonProperty("id") Integer id, @JsonProperty("attributes") TransitionAttributes attributes) {
super(id);
this.attributes = attributes;
}
@JacksonXmlProperty(localName = "attributes")
public TransitionAttributes getAttributes() {
return attributes;
}
}
And its inner class:
@JacksonXmlRootElement(localName = "attributes")
public class TransitionAttributes {
private Event event;
private List<Action> actions;
private String code;
private String guard;
@JacksonXmlProperty(localName = "action")
@JacksonXmlElementWrapper(useWrapping = false)
public List<Action> getActions() {
return actions;
}
}
Method "getActions" also returns empty list, when type-attribute of widget is missing while defaultImpl is specified.
This is checked with Jackson 2.8.8 and 2.9.0.pr3.
Metadata
Metadata
Assignees
Labels
No labels