I would like to know how I can get the JAXB compiler to make certain elements in my XML schema declared as final in the java class definition, and I would also like to be able to control various constructors, as in that I would like a constructor that can create an object with a complete list of parameters contained in the class, as well as the default private constructor required by JAXB.
Any help?
Thank.
Here is an example of what I'm trying to do:
<xs:complexType name="mycomplex">
<xs:all>
<xs:element name="myboolean" type="xs:boolean"/>
</xs:all>
</xs:complexType>
now the generated code will look something like this:
public class mycomplex
{
protected boolean myboolean;
public boolean getMyboolean() { return myboolean; }
public void setMyboolean(boolean b) { this.myboolean = b; }
}
but I would like to edit the scheme so that it looks like this:
public class mycomplex
{
protected final boolean myboolean;
public mycomplex(boolean b) { this.myboolean = b; }
public boolean getMyboolean() { return myboolean; }
}
Can this be achieved?
source
share