Version 0.11.0
Release notes
- JAXBEqualsStrategy is now symmetic (#22)
- Plugins now consider
xjc:superClass
(#42) - Plugins now consider default values (#26, #37, #38, #44, #45, #46, #47)
All issues, fixed in this release
Backwards compatibility
This release mak break backwards compatibility.
Supporting default values
This release fixed a number of issues related to the support of default values (#26, #37, #38, #44, #45, #46, #47).
In certain cases properties may have default values. For instance, it may correspond to an attribute with default value:
<xs:attribute name="testBoolean" type="xs:boolean" default="true"/>
Here's the getter that XJC generates for such a property:
public boolean isTestBoolean() {
if (testBoolean == null) {
return true;
} else {
return testBoolean;
}
}
So the default value is not actually assigned to the field, it is returned from the getter if the field is not set.
With this release, default values are considered by the JAXB2 Basics plugins. You will typically get the following code for property accessors:
boolean theTestBoolean = (this.isSetTestBoolean()?this.isTestBoolean():true);
In previous versions, default values were ignored. This changes now and this change is not backwards compatible.
Considering "is value set" in strategies
Support for default values which was fixed in this version poses a new challenge.
Since we now consider default values of properties, how do you distinguish properties with explicitly set values versus properties with default values?
It is important to consider this difference. For instance, if you create a copy of an object, it wouldn't be correct to copy default values. Or if you merge two values, you'll probably choose explicitly assigned values over default values.
This means you have to know when the values was explicitly assigned and when this values is default.
To support this, it was necessary to extend existing strategis with parameters which describe if provided values are explicitly set in objects. A typical change is from:
public boolean copy(ObjectLocator locator, boolean value);
To:
public boolean copy(ObjectLocator locator, boolean value, boolean valueSet);
To support this change, we now have new strategies:
org.jvnet.jaxb2_commons.lang.HashCodeStrategy2
org.jvnet.jaxb2_commons.lang.EqualsStrategy2
org.jvnet.jaxb2_commons.lang.ToStingStrategy2
org.jvnet.jaxb2_commons.lang.CopyStrategy2
org.jvnet.jaxb2_commons.lang.MergeStrategy2
Old strategies are now deprecated:
org.jvnet.jaxb2_commons.lang.HashCodeStrategy
org.jvnet.jaxb2_commons.lang.EqualsStrategy
org.jvnet.jaxb2_commons.lang.ToStingStrategy
org.jvnet.jaxb2_commons.lang.CopyStrategy
org.jvnet.jaxb2_commons.lang.MergeStrategy
We also have new interfaces for schema-derived classes:
org.jvnet.jaxb2_commons.lang.HashCode2
org.jvnet.jaxb2_commons.lang.Equals2
org.jvnet.jaxb2_commons.lang.ToSting2
org.jvnet.jaxb2_commons.lang.Copy2
org.jvnet.jaxb2_commons.lang.Merge2
Old interfaces are now deprecated:
org.jvnet.jaxb2_commons.lang.HashCode
org.jvnet.jaxb2_commons.lang.Equals
org.jvnet.jaxb2_commons.lang.ToSting
org.jvnet.jaxb2_commons.lang.Copy
org.jvnet.jaxb2_commons.lang.Merge
Existing strategies now implement both new as well as old (deprecated) strategy interfaces:
org.jvnet.jaxb2_commons.lang.DefaultHashCodeStrategy
/org.jvnet.jaxb2_commons.lang.JAXBHashCodeStrategy
org.jvnet.jaxb2_commons.lang.DefaultEqualsStrategy
/org.jvnet.jaxb2_commons.lang.JAXBEqualsStrategy
org.jvnet.jaxb2_commons.lang.DefaultToStringStrategy
/org.jvnet.jaxb2_commons.lang.JAXBToStringStrategy
org.jvnet.jaxb2_commons.lang.DefaultCopyStrategy
/org.jvnet.jaxb2_commons.lang.JAXBCopyStrategy
org.jvnet.jaxb2_commons.lang.DefaultMergeStrategy
/org.jvnet.jaxb2_commons.lang.JAXBMergeStrategy
This means that new version of the JAXB2 Basics runtime should be backwards compatible with the old generated code. You don't necessarily need to regenerate your code to use the new runtime. However if you do regenerate your code, you'll have to use the new runtime. This may or may not be backwards compatible.
If you just generate code with JAXB2 Basics and use the default strategies provided in the JAXB2 Basics runtime, there should be no problem. However, if you have implemented your own strategies, you may need to update them.