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

Generate fields for all Identityrefs in an Union binding class.

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Low Low
    • 10.0.0
    • None
    • Binding codegen
    • None

      Yang allows adding multiple identityrefs as possible types in an Union. For example:

      identity compliance-code-identity {
        description
          "Base identity for reporting pluggable compliance codes per port.";
      } 
      
      identity network-phy-code-identity {
        description
          "base identity for network phy code.";
      }
        
      identity client-phy-code-identity {
        description
          "base identity for client phy code.";
      }
      
      type union {
        type identityref { base compliance-code-identity; }
        type identityref { base client-phy-code-identity; }
        type identityref { base network-phy-code-identity; }
        type uint64;
        type decimal64 {
          fraction-digits 8;
        } 
      }
      

      However when MDSAL generates binding class for this union, it only contains the first Identityref specified. In this case the compliance-code-identity.
      Binding generator processes the "identityref" as an ordinary "type" and therefore it ignores multiple occurencies of it, just as it does for any other type. But Identityref isn't an ordinary type, so it should be processed differently.
      The result is as follows:

      public class ComplianceCodesUnion implements TypeObject, Serializable {
        private static final long serialVersionUID = -3780142905034216089L;
        private final Class<? extends ComplianceCodeIdentity> _identityref;
        private final BigInteger _uint64;
        private final BigDecimal _decimal64;
      

      Modify the binding generator to include all the identityrefs.

       

            ojo Oleksandr Zharov
            tibor.kral Tibor Král
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: