title: JAXB Code Inject into Enum Class
body: <p>The background problem is when we reflect on a JAXB generated <code>Enum</code> class, <code>toString()</code> is called which without an <code>@override</code> of <code>toString()</code> will return <code>.name()</code> instead of <code>.value()</code>. So, I would like to inject my own <code>toString()</code>.</p>
  
  <p>I am unable to inject code into a JAXB generated <code>Enum</code> class. Although, I am able to inject code at the top level <code>complexType</code> and but not in the inline <code>Enum</code> class.</p>
  
  <p>Here is the section of the XSD in question seen below (I have tried absolute and relative):</p>
  
  <pre><code> &lt;jxb:bindings node="/xs:schema/xs:complexType[@name='QueryPgm']/xs:sequence/xs:element[@name='STATUS']/xs:simpleType"&gt;
  </code></pre>
  
  <p>I use these args: </p>
  
  <pre><code>"-verbose -Xinject-code -extension"
  </code></pre>
  
  <p>No errors appear and the output is:</p>
  
  <pre>
    parsing a schema...
    compiling a schema...
    [INFO] generating code
    unknown location
    com/ibm/query/pgm/ObjectFactory
    com/ibm/query/pgm/QueryPgm
    com/ibm/query/pgm/package-info
  </pre>
  
  <p>Here is the section of the schema in question: </p>
  
  <pre><code>&lt;xs:complexType name="QueryPgm"&gt;
  &lt;xs:sequence&gt;
      &lt;xs:element name="NAME" type="tns:nameOptions" minOccurs="1" maxOccurs="unbounded" /&gt;
  
      &lt;xs:element name="SHOW" minOccurs="0" maxOccurs="unbounded"&gt;
          &lt;xs:simpleType&gt;
              &lt;xs:annotation&gt;
                  &lt;xs:appinfo&gt;
                      &lt;jxb:typesafeEnumClass name="showOptions"/&gt;
                  &lt;/xs:appinfo&gt;
              &lt;/xs:annotation&gt;
              &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:enumeration value="ALL" /&gt;
              &lt;/xs:restriction&gt;
          &lt;/xs:simpleType&gt;
      &lt;/xs:element&gt;
  
      &lt;xs:element name="STATUS" minOccurs="0" maxOccurs="unbounded"&gt;
          &lt;xs:simpleType&gt;
              &lt;xs:annotation&gt;
                  &lt;xs:appinfo&gt;
                      &lt;jxb:typesafeEnumClass name="statusOptions"/&gt;
  
                      &lt;jxb:bindings node="/xs:schema/xs:complexType[@name='QueryPgm']/xs:sequence/xs:element[@name='STATUS']/xs:simpleType"&gt;
                          &lt;ci:code&gt;
                              @Override
                              public String toString() { return this.value();}
                          &lt;/ci:code&gt;
                      &lt;/jxb:bindings&gt;
                  &lt;/xs:appinfo&gt;
              &lt;/xs:annotation&gt;
  
              &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:enumeration value="DB-NOTAVL" /&gt;
                  &lt;xs:enumeration value="IOPREV" /&gt;
                  &lt;xs:enumeration value="LOCK" /&gt;
                  &lt;xs:enumeration value="NOTINIT" /&gt;
                  &lt;xs:enumeration value="STOSCHD" /&gt;
                  &lt;xs:enumeration value="TRACE" /&gt;
              &lt;/xs:restriction&gt;
          &lt;/xs:simpleType&gt;
      &lt;/xs:element&gt;
  &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  </code></pre>
  
  <p>I would appreciate help or ideas one might have. Thanks. </p>