Details
-
Improvement
-
Status: Resolved
-
Medium
-
Resolution: Done
-
None
-
None
Description
We have the following code generated here:
public VlanId(Id _id) {
super();
this._id = _id;
this._enumeration = null;
}
public VlanId(Enumeration _enumeration) {
super();
this._enumeration = _enumeration;
this._id = null;
}
in org.opendaylight.yang.gen.v1.urn.test.rev170101.Cont.java.
This works in general, but it allows invalid objects to be created – if the argument is null, we end up with a union which is neither one or the other:
public VlanId(Id _id) {
super();
this._id = Objects.requireNonNull(_id);
this._enumeration = null;
}
public VlanId(Enumeration _enumeration) {
super();
this._enumeration = Objects.requireNonNull(_enumeration);
this._id = null;
}