From 340807976258b77ecc0555d9f5ac0181c57f429e Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 21 May 2014 11:40:36 +0200 Subject: [PATCH] BUG-509: merge InMemoryDataTreeModification.resolveSnapshot() This patch adds some minimal documentation and merges the two resolveSnapshot() methods into one, making the call stack a bit easier to understand. Change-Id: Ib23fccdc9d2987aa255483becc63155904ebc332 Signed-off-by: Robert Varga --- .../data/InMemoryDataTreeModification.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeModification.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeModification.java index df3ef8b7e1..1540feca66 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeModification.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeModification.java @@ -88,21 +88,22 @@ final class InMemoryDataTreeModification implements DataTreeModification { @Override public Optional> readNode(final InstanceIdentifier path) { - Entry modification = TreeNodeUtils.findClosestsOrFirstMatch(rootNode, path, NodeModification.IS_TERMINAL_PREDICATE); - - Optional result = resolveSnapshot(modification); + /* + * Walk the tree from the top, looking for the first node between root and + * the requested path which has been modified. If no such node exists, + * we use the node itself. + */ + final Entry entry = TreeNodeUtils.findClosestsOrFirstMatch(rootNode, path, NodeModification.IS_TERMINAL_PREDICATE); + final InstanceIdentifier key = entry.getKey(); + final NodeModification mod = entry.getValue(); + + final Optional result = resolveSnapshot(key, mod); if (result.isPresent()) { NormalizedNode data = result.get().getData(); - return NormalizedNodeUtils.findNode(modification.getKey(), data, path); + return NormalizedNodeUtils.findNode(key, data, path); + } else { + return Optional.absent(); } - return Optional.absent(); - } - - private Optional resolveSnapshot( - final Entry keyModification) { - InstanceIdentifier path = keyModification.getKey(); - NodeModification modification = keyModification.getValue(); - return resolveSnapshot(path, modification); } private Optional resolveSnapshot(final InstanceIdentifier path, -- 2.36.6