Details
-
Improvement
-
Status: Resolved
-
High
-
Resolution: Done
-
None
-
None
Description
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:
- default order-by is "system", yet we are married to order-dependent List.equals(), yet
- the BI layer will interpret this as a freely-reorderable Map
- 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().
Attachments
Issue Links
- relates to
-
MDSAL-540 Remove compatibility Builder.setFoo(List<Foo>)
-
- Resolved
-
| # | Subject | Branch | Project | Status | CR | V |
|---|---|---|---|---|---|---|
| 85824,12 | Add CodeHelpers.nonnull(Map) | master | mdsal | Status: MERGED | +2 | +1 |
| 85825,15 | Handle java.util.Map return type | master | mdsal | Status: MERGED | +2 | +1 |
| 85826,6 | WIP: add Types.isMapType() | master | mdsal | Status: ABANDONED | 0 | +1 |
| 85827,21 | Map system-ordered keyed lists to Map | master | mdsal | Status: MERGED | +2 | +1 |
| 89309,3 | Generate legacy List adaptation | master | mdsal | Status: MERGED | +2 | +1 |