Q:

Can the XmlElement annotation have multiple types?

I have a list that is of a super type, i.e.
List<IFoo> foo

The list contains objects from two different subtypes:
public class FooBar implements IFoo{
}

public class FooType implements IFoo{
}

Is there are way to add multple types to the XmlElement annotation, i.e.
XmlElement(type={FooBar.class, FooType.class)
List<IFoo> foo

A:

You can have multiple types for a list by using the annotation XmlElements.
E.g.
@XmlElements({
    @XmlElement(type=FooBar.class),
    @XmlElement(type=FooType.class)
})
List<IFoo> foo;

