summaryrefslogtreecommitdiffstats
path: root/infra/data-impl
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-02-10 12:25:37 +0100
committerMarek Gradzki <mgradzki@cisco.com>2017-02-10 13:04:43 +0100
commit66fa7ccd196c000c15203f9968beed698ba06b76 (patch)
tree16f742b433906e327bb7d3da347e229406367c03 /infra/data-impl
parentde55d1e7c1fa5517ee6eabcd3fa23e5b5136d64b (diff)
Fix support for nested augmentations when augmenting lists
Change-Id: I96e7db8f295c9c3d5b14395c7785574d12d76ea9 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'infra/data-impl')
-rw-r--r--infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModificationDiff.java34
1 files changed, 26 insertions, 8 deletions
diff --git a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModificationDiff.java b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModificationDiff.java
index 9903d99fc..863f8abb2 100644
--- a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModificationDiff.java
+++ b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModificationDiff.java
@@ -299,15 +299,26 @@ final class ModificationDiff {
// yangtools. The hierarchy does not use e.g. SchemaNode class for all types
private final Object parentNode;
private final Object schemaNode;
+ private final boolean updateParentNode;
- Modification(final YangInstanceIdentifier id,
- final DataTreeCandidateNode dataCandidate,
- final Object parentNode,
- final Object schemaNode) {
+ private Modification(final YangInstanceIdentifier id,
+ final DataTreeCandidateNode dataCandidate,
+ final Object parentNode,
+ final Object schemaNode,
+ final boolean updateParentNode) {
this.id = id;
this.dataCandidate = dataCandidate;
this.parentNode = parentNode;
this.schemaNode = schemaNode;
+ // controls process of updating parent node while moving down the schema tree:
+ this.updateParentNode = updateParentNode;
+ }
+
+ Modification(final YangInstanceIdentifier id,
+ final DataTreeCandidateNode dataCandidate,
+ final Object parentNode,
+ final Object schemaNode) {
+ this(id, dataCandidate, parentNode, schemaNode, true);
}
Modification(final YangInstanceIdentifier id,
@@ -397,12 +408,19 @@ final class ModificationDiff {
.map(child -> {
final YangInstanceIdentifier childId = id.node(child.getIdentifier());
final Object schemaChild = schemaChild(schemaNode, child.getIdentifier());
+
// An augment cannot change other augment, so we do not update parent node if we are streaming
// children of AugmentationSchema (otherwise we would fail to find schema for nested augmentations):
- final Object newParent = (schemaNode instanceof AugmentationSchema)
- ? parentNode
- : schemaNode;
- return new Modification(childId, child, newParent, schemaChild);
+ if (updateParentNode) {
+ if (schemaNode instanceof AugmentationSchema) {
+ // child nodes would not have nested augmentations, so we stop moving parentNode:
+ return new Modification(childId, child, parentNode, schemaChild, false);
+ } else {
+ // update parent node:
+ return new Modification(childId, child, schemaNode, schemaChild, true);
+ }
+ }
+ return new Modification(childId, child, parentNode, schemaChild, updateParentNode);
});
}