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

Fix unordered keyed list mapping

XMLWordPrintable

      Due to legacy reasons, the following snippet:

      container foo {
          list bar {
              key baz;
              leaf baz {
                  type string;
              }
          }
      }
      

      ends up being mapped as this:

      interface Foo {
          List<Bar> getBar();
      }
      

      which ends up being nasty for multiple reasons:

      1. default order-by is "system", yet we are married to order-dependent List.equals(), yet
      2. the BI layer will interpret this as a freely-reorderable Map
      3. there is no provision to look up elements by their key and hence users must perform linear searches

      The mapping for keyed lists with "order-by system", the mapping should result in the following:

      interface Foo {
          Map<BarKey, Bar> getBar();
      }
      

      which properly captures the contract here, binding use to Map.equals(). Note that unkeyed lists must not be affected, nor should the "order-by user" lists be changed.

      For dealing with user-ordered lists we will need a custom interface, which is an extension of List and provides a secondary map-like lookups, still deriving equality from List.equals().

       

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

              Created:
              Updated:
              Resolved: