title: Programmatically determine if a JAXB annotation will result in a xsi:type annotation?
body: <p>Reflecting on JAXB annotated objects, is there a way to determine if a class/field/method will result in a xsi:type attributed during marshaling?</p>
  
  <p>Is XmlElement annotation,<br>
  <code>annotation.type != javax.xml.bind.annotation.XmlElement.DEFAULT.class</code><br>
   the only case I need to worry about?</p>
  
  <p>I'm writing a Lua unmarshaler where we have dropped much of the usual xml type info and I'm trying to figure-out how to match the incoming Lua to JAXB.</p>
  
  <p>Thanks.</p>
  
  <p>--Update--</p>
  
  <p>Here is simple example that shows the problem:</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlRootElement()
  @XmlSeeAlso({ Cat.class, Dog.class })
  public class Animal {
    @XmlElement()
    public List&lt;Animal&gt; critters;
    @XmlAttribute
    public String type;
  }
  
  @XmlAccessorType(XmlAccessType.FIELD)
  @XmlRootElement()
  public class Dog extends Animal {
    public Dog() {
      this.type = "German Shepherd";
    }
  }
  
  @XmlAccessorType(XmlAccessType.FIELD)
  @XmlRootElement()
  public class Cat extends Animal {
    public Cat() {
      this.type = "Black";
    }
  }
  </code></pre>
  
  <p>When I receive an Animal object can I query critter's annotation to detect that it should be a Dog or Cat and not an Animal?</p>