diff options
author | Maros Marsalek <mmarsale@cisco.com> | 2016-06-22 14:35:29 +0200 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2016-06-23 09:50:32 +0000 |
commit | 5468a61fef3ac8ec4744a42f035c39b192cdde1d (patch) | |
tree | a9b0deb23620edafbb16c46edec88394a8039e80 /v3po/data-impl/src/main | |
parent | 989e659602f539ec26be4b39203a4fb27102bb69 (diff) |
HONEYCOMB-92 Ignore empty modifications for e.g. empty presence containers
Change-Id: I565686dbd2474fffbfea4e8cc837861845723bda
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'v3po/data-impl/src/main')
-rw-r--r-- | v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/ModifiableDataTreeDelegator.java | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/ModifiableDataTreeDelegator.java b/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/ModifiableDataTreeDelegator.java index c8d258b43..91de1885e 100644 --- a/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/ModifiableDataTreeDelegator.java +++ b/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/ModifiableDataTreeDelegator.java @@ -178,7 +178,7 @@ public final class ModifiableDataTreeDelegator extends ModifiableDataTreeManager final HashMap<InstanceIdentifier<?>, DataObject> transformed = new HashMap<>(biNodes.size()); for (Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> biEntry : biNodes.entrySet()) { final Map.Entry<InstanceIdentifier<?>, DataObject> baEntry = serializer.fromNormalizedNode(biEntry.getKey(), biEntry.getValue()); - if(baEntry != null) { + if (baEntry != null) { transformed.put(baEntry.getKey(), baEntry.getValue()); } } @@ -253,7 +253,7 @@ public final class ModifiableDataTreeDelegator extends ModifiableDataTreeManager } /** - * Produce a diff from a candidate node recursively + * Produce a diff from a candidate node recursively. */ @Nonnull static ModificationDiff recursivelyFromCandidate(@Nonnull final YangInstanceIdentifier yangIid, @@ -266,9 +266,9 @@ public final class ModifiableDataTreeDelegator extends ModifiableDataTreeManager return ModificationDiff.EMPTY_DIFF; } case WRITE: { - return currentCandidate.getDataBefore().isPresent() ? - ModificationDiff.create(yangIid, currentCandidate) : - ModificationDiff.createFromAfter(yangIid, currentCandidate); + return currentCandidate.getDataBefore().isPresent() + ? ModificationDiff.create(yangIid, currentCandidate) + : ModificationDiff.createFromAfter(yangIid, currentCandidate); // TODO HONEYCOMB-94 process children recursively to get modifications for child nodes } case DELETE: @@ -282,10 +282,9 @@ public final class ModifiableDataTreeDelegator extends ModifiableDataTreeManager // and that messes up our modifications collection here, so we need to skip .filter(ModificationDiff::isModification) .map(child -> LEAF_MODIFICATIONS.contains(child.getModificationType())) - .reduce((aBoolean, aBoolean2) -> aBoolean || aBoolean2); + .reduce((boolOne, boolTwo) -> boolOne || boolTwo); - // - if(leavesModified.isPresent() && leavesModified.get()) { + if (leavesModified.isPresent() && leavesModified.get()) { return ModificationDiff.create(yangIid, currentCandidate); // TODO HONEYCOMB-94 process children recursively to get modifications for child nodes even if current // was modified @@ -309,33 +308,34 @@ public final class ModifiableDataTreeDelegator extends ModifiableDataTreeManager * Check whether candidate.before and candidate.after is different. If not * return false. */ - private static boolean isModification(final DataTreeCandidateNode a) { - if(a.getDataBefore().isPresent()) { - if(a.getDataAfter().isPresent()) { - return !a.getDataAfter().get().equals(a.getDataBefore().get()); + private static boolean isModification(final DataTreeCandidateNode candidateNode) { + if (candidateNode.getDataBefore().isPresent()) { + if (candidateNode.getDataAfter().isPresent()) { + return !candidateNode.getDataAfter().get().equals(candidateNode.getDataBefore().get()); } else { return true; } } - return true; + // considering not a modification if data after is also null + return candidateNode.getDataAfter().isPresent(); } /** - * Check whether candidate node is for a leaf type node + * Check whether candidate node is for a leaf type node. */ - private static boolean isLeaf(final DataTreeCandidateNode a) { - return a.getDataAfter().isPresent() - ? (a.getDataAfter().get() instanceof LeafNode<?>) - : (a.getDataBefore().get() instanceof LeafNode<?>); + private static boolean isLeaf(final DataTreeCandidateNode candidateNode) { + // orNull intentional, some candidate nodes have both data after and data before null + return candidateNode.getDataAfter().orNull() instanceof LeafNode<?> + || candidateNode.getDataBefore().orNull() instanceof LeafNode<?>; } @Override public String toString() { - return "ModificationDiff{" + - "modificationsBefore=" + modificationsBefore + - ", modificationsAfter=" + modificationsAfter + - '}'; + return "ModificationDiff{" + + "modificationsBefore=" + modificationsBefore + + ", modificationsAfter=" + modificationsAfter + + '}'; } } } |