When unmarshalling using jaxb, I have in class A something along:
public class A {
@XmlElements( { //
@XmlElement(name = "g", type = A.class),
@XmlElement(name = "x", type = X.class),
@XmlElement(name = "y", type = Y.class),
})
List<XXX> children;
}
That is, I have a list, children, consisting of X:s and Y:s
Now for my question: I would like to subclass A, and I would like to redefine the 'XmlElements' list and bind it to the same variable, 'children', like:
public class B extends A {
@XmlElements( { //
@XmlElement(name = "g", type = B.class),
@XmlElement(name = "x", type = X.class),
@XmlElement(name = "y", type = Y.class),
@XmlElement(name = "z", type = Z.class),
})
List<XXX> children;
}
The issues with the above are twofold:
I create a new variable children, I would like to refer to the variable in class A.
I would like to avoid respecifying the 'x' and 'y' since they are already specified in 'A'.
Is there some good pattern to achieve this?
Or some pointers/articles or other info for how to build something like this?