[YANGTOOLS-1392] Reformulate ImmutableNodes.fromInstanceId() in terms of NormalizedNodeStreamWriter Created: 28/Jan/22 Updated: 10/May/22 Resolved: 11/Mar/22 |
|
| Status: | Resolved |
| Project: | yangtools |
| Component/s: | data-api, data-impl |
| Affects Version/s: | None |
| Fix Version/s: | 8.0.0 |
| Type: | New Feature | Priority: | Medium |
| Reporter: | Robert Varga | Assignee: | Tomas Cere |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||
| Description |
|
We have a way to construct a NormalizedNode hierarchy, which is sadly tied to a particular implementation. There are a few use cases, where we really mean to push the state of a YangInstanceIdentifier into a NormalizedNodeStreamWriter and then emit a number of NormalizedNodes and close the identifier. Refactoring this utility method would allow users side-step the NormalizedNode representation and ditch quite a bit of complexity – with the following construct: YangInstanceIdentifier id = ...; NormalizedNodeStreamWriter writer = ...; try (var nnWriter = NormalizedNodeWriter.forStreamWriter(writer)) { try (var idCtx = nnWriter.enterPath(id)) { // here we have emitted the events to 'enter' structure indicated by the id // and can proceed to, for example nnWriter.writeNormalizedNode(...); } // here we are again outside of the id, having rolled back the changes } |
| Comments |
| Comment by Robert Varga [ 10/Mar/22 ] |
|
The actual implementation is named YangInstanceIdentifierWriter and is instantiated through an 'open()' static method, which returns an Autocloseable instance. |