Reputation: 2726
Using jaxb2-maven-plugin and jaxb-xjc, while generating classes jaxb creates boolean accessors with get prefix however I want it to create with java convention "is".
here is the xsd:
<xsd:complexType name="QueryWorkgroupRequestType">
<xsd:sequence>
...
<xsd:element name="disabled" type="xsd:boolean" minOccurs="0" maxOccurs="1" />
...
</xsd:sequence>
</xsd:complexType>
and the created method is;
public Boolean getDisabled() {
return disabled;
}
But I want instead;
public Boolean isDisabled() {
return disabled;
}
I tried
<xsd:annotation>
<xsd:appinfo>
<jaxb:globalBindings enableJavaNamingConventions="true" generateIsSetMethod="true"/>
</xsd:appinfo>
</xsd:annotation>
but no chance.
** SOLVED **
Well at last I could sort out the problem, maven was using jdk 1.8, somehow using 1.8 masses it up. Using 1.6 fixed it, works as desired now.
Upvotes: 5
Views: 4326
Reputation: 122414
The is
prefix for Java Bean accessor methods is only valid for properties of the primitive type boolean
. For all other types (including the java.lang.Boolean
reference type) the only valid prefix that will be recognised as a bean property accessor is get
.
If the element were not nullable (i.e. it didn't have minOccurs="0"
) then it would be bound to a property of type boolean
rather than Boolean
and would get an is
accessor.
Upvotes: 8