[YANGTOOLS-1022] Rework NormalizedNode class hierarchy and design Created: 30/Aug/19  Updated: 23/Nov/23

Status: Confirmed
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: 14.0.0

Type: Epic Priority: High
Reporter: Robert Varga Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
relates to YANGTOOLS-1455 Data change event notification fails Resolved
Epic Name: Redesign NormalizedNode

 Description   

NormalizedNode interface has a number of deficiencies, which make it non-trivial to use and implement.

Most notably:

  1. it uses generics to capture identifier type and value type
  2. it generalizes that all NormalizedNodes have value, which would seem to indicate it can be used for comparison, but
  3. NormalizedNodeContainer.getValue() codifies it to a Collection, which wrecks equality contract, and
  4. That contract is not really accurate, as all implementations really want to say Set, but they are also implementing the contract through a Map, which does not have a valueSet() and entrySet() actually is not useful

While we cannot get rid of the generic type for identifier type (as it leads to Identifiable<T>), we should eliminate the notion that a raw normalized node has a value and reserve that to ValueNodes only. Furthermore the notion of children being present needs to be abstracted towards the end specializations, so they can provide an accurate view based on semantics.

For NormalizedNodeContainer this amounts to replicating java.util.Map contract, with the inherent understanding that children are unique based on their identifier – essentially the map there interpret NormalizedNode as an Entry<node.getIdentifier(), node> when adding them. Note that NormalizedNode cannot be an Entry, as it inherently would violate the Entry.hashCode() contract.



 Comments   
Comment by Robert Varga [ 13/Nov/20 ]

There is a further wrinkle of not being able to identify ItemOrdering – which is explicit incompatible contract. We effectively need to split MapNode into MapNode<O> and UnorderedMapNode.

Generated at Wed Feb 07 20:54:57 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.