I am using JAXB for generating beans from XSD's using a JAXB plugin in Maven. This is working fine, expect that the code contains isSetXXXXXX() methods for each field.
e.g.
for a field firstName, it is producing the following code:
@XmlElement(name = "FirstName", required = true)
protected String firstName;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.token = firstName;
}
public boolean isSetFirstName() {
return (this.firstName!= null);
}
This isSetFirstName() method is causing issues and I don't want JAXB to generate these.
Is there a way to stop this behaviour?
Thanks.
UPDATE
Solved this: Problem was in the xjb file, generateIsSetMethod was set to true.
<xs:annotation>
<xs:appinfo>
<jaxb:globalBindings generateIsSetMethod="true">
bindingStyle="modelGroupBinding"
choiceContentProperty="true" >
<xjc:serializable uid="12343"/>
<jaxb:javaType name="short"
xmlType="xs:long"
printMethod="javax.xml.bind.DatatypeConverter.printShort"
parseMethod="javax.xml.bind.DatatypeConverter.parseShort"/>
</jaxb:globalBindings>
</xs:appinfo>
</xs:annotation>
And this answered my previous question as well.
By default a JAXB (JSR-222) implementation will not generate isSet
methods. Since you are getting them one of the following must be true:
<jaxb:globalBindings generateIsSetMethod="true"/>
<jaxb:globalBindings generateIsSetMethod="true"/>
isSet
methods.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With