Details
Description
When generating Java classes from XSD, primitive Java types (such as `int` or `boolean`) are used for the corresponding XML types.
When an element is nullable, an additional `isNilFoo()` method allows the user to query that.
As I understand it, the corresponding `getFoo()` method always returns a value, even when the `foo` element is null. That makes it very easy to accidentally read bogus data from a null element.
Several other XML data binding frameworks use objects in that case (e.g. `Integer` instead of `int`), which has the advantage that accidentally reading a null value will throw an NPE rather than let the code continue to run on bogus data.
My suggestion is to follow that example. Since backward compatibility is likely a requirement, this behavior could be made configurable via a command-line switch in `scomp`.
If for whatever reason this is not a feasible solution, an alternate approach would be to generate getter methods like this:
public int getFoo() {
if (isNilFoo())
throw new IllegalStateException("attempt to read from null member: foo");
return foo;
}