I have the following:
class A{
@XmlElement
String name;
//getters and setters
}
and
class B extends A{
@XmlElement
String height;
//getters and setters
}
finally I have
@XmlRootElement
class P{
@XmlElement
List<A> things;
//getters and setters
}
If I do
List<A> l = new ArrayList<A>();
l.add(new B('hello', 20)) //Add new B with height of 20 and name hello
P p = new P();
p.setThings(l); //Set things to list of B's.
and marshal P, I only get the field as part of things and not height.
I know that I can add @XmlSeeAlso(B.class) in A and it will all work.
But the issue is that I don't know all extended classes other than B, as A may be extended on runtime.
How do I dynamically define @XmlSeeAlso on runtime?