Uploaded image for project: 'mdsal'
  1. mdsal
  2. MDSAL-792

Union value classes need to enforce non-null components

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Medium Medium
    • 11.0.0, 10.0.4
    • None
    • Binding codegen
    • None

      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;
              } 

       

            rovarga Robert Varga
            rovarga Robert Varga
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: