-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
Description
I spotted this issue while investigating #124, but I do not have any ideas for a potential fix.
Using the same example as in the linked issue, with -Ximm-optionalgetter
enabled, and based on the same XSD snippet:
<xs:element name="DecimalExtensionType">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="BaseType">
<xs:attribute name="unit" fixed="s"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:simpleType name="BaseType">
<xs:restriction base="xs:decimal">
<xs:fractionDigits value="3"/>
</xs:restriction>
</xs:simpleType>
Note that the code originally generated to get the unit attribute value is:
public String getUnit() {
if (unit == null) {
return "s";
} else {
return unit;
}
}
However, since this is not a required attribute this getter is replaced with:
public Optional<String> getUnit() {
return Optional.ofNullable(unit);
}
The default value that was intended to be returned from fixed="s"
is however lost because of this. As a side note, the original getters are also generated with javadoc, which is also lost when using this plugin, but the generated javadoc comment does not contain any information that isn't in the method signature so I don't think its worth filing an issue for this.