Closed techteam-bln closed 6 months ago
Same here. Problem is that it treats Calendar fields the same as complex objects, and it tried to make separate fields for Calendar fields. It should treat Calendar as a normal standard Java type, same as String or Integer.
For example for a simple test class with three fields, one is a date with the above java.util.Calendar conversion. This is pretty common when using XJC.
XSD:
<xsd:complexType name="TestFieldType">
<xsd:sequence>
<xsd:element name="testString" type="xsd:string"></xsd:element>
<xsd:element name="testDate" type="xsd:date"></xsd:element>
<xsd:element name="testNumber" type="xsd:int"></xsd:element>
</xsd:sequence>
</xsd:complexType>
Generated Java:
public class TestFieldType implements Serializable
{
private final static long serialVersionUID = 1L;
@XmlElement(required = true)
protected String testString;
@XmlElement(required = true, type = String.class)
@XmlJavaTypeAdapter(Adapter2 .class)
@XmlSchemaType(name = "date")
protected Calendar testDate;
protected int testNumber;
...
public<_B >void copyTo(final TestFieldType.Builder<_B> _other) {
_other.testString = this.testString;
_other.testDate = ((this.testDate == null)?null:this.testDate.newCopyBuilder(_other)); // ERROR - no newCopyBuilder for testDate
_other.testNumber = this.testNumber;
}
...
public static class Builder<_B >implements Buildable
{
protected final _B _parentBuilder;
protected final TestFieldType _storedValue;
private String testString;
private Calendar.Builder<TestFieldType.Builder<_B>> testDate; // ERROR - no Builder class for testDate
private int testNumber;
...
}
}
It is designed to apply the builder patterns only to instances of classes defined within the current XML schema domain, so this is actually strange. I'll have a look into this...
Fixed in 4.1.0
Thanks a lot!
Version 4.1.0 has just been released. It may take a while to appear on maven central, but it should be available soon.
If you define an xs:date field in an xml schema and define global bindings with: