X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-data-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fdata%2Fimpl%2Fschema%2Ftree%2FModifiedNode.java;h=35da5d3650a4c87987b46679acb1625461e5c880;hb=f6eae2a11c570c1097eb9202debc7e36ce72ef6d;hp=be0ed682adf111f79b9148bdfdb4953fc5045dcc;hpb=556f7f7e746d122eff237e4e872a6cda8c1de4f4;p=yangtools.git diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ModifiedNode.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ModifiedNode.java index be0ed682ad..35da5d3650 100644 --- a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ModifiedNode.java +++ b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ModifiedNode.java @@ -27,8 +27,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version; * Node Modification Node and Tree * * Tree which structurally resembles data tree and captures client modifications to the data store tree. This tree is - * lazily created and populated via {@link #modifyChild(PathArgument)} and {@link TreeNode} which represents original - * state as tracked by {@link #getOriginal()}. + * lazily created and populated via {@link #modifyChild(PathArgument, ModificationApplyOperation, Version)} and + * {@link TreeNode} which represents original state as tracked by {@link #getOriginal()}. * * The contract is that the state information exposed here preserves the temporal ordering of whatever modifications * were executed. A child's effects pertain to data node as modified by its ancestors. This means that in order to @@ -37,11 +37,9 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version; */ @NotThreadSafe final class ModifiedNode extends NodeModification implements StoreTreeNode { - static final Predicate IS_TERMINAL_PREDICATE = new Predicate() { - @Override - public boolean apply(@Nonnull final ModifiedNode input) { - Preconditions.checkNotNull(input); - switch (input.getOperation()) { + static final Predicate IS_TERMINAL_PREDICATE = input -> { + Preconditions.checkNotNull(input); + switch (input.getOperation()) { case DELETE: case MERGE: case WRITE: @@ -49,10 +47,9 @@ final class ModifiedNode extends NodeModification implements StoreTreeNode children; @@ -66,6 +63,11 @@ final class ModifiedNode extends NodeModification implements StoreTreeNode validatedCurrent; + private TreeNode validatedNode; + private ModifiedNode(final PathArgument identifier, final Optional original, final ChildTrackingPolicy childPolicy) { this.identifier = identifier; this.original = original; @@ -109,11 +111,11 @@ final class ModifiedNode extends NodeModification implements StoreTreeNode getChild(final PathArgument child) { - return Optional. fromNullable(children.get(child)); + return Optional.fromNullable(children.get(child)); } private Optional metadataFromSnapshot(@Nonnull final PathArgument child) { - return original.isPresent() ? original.get().getChild(child) : Optional.absent(); + return original.isPresent() ? original.get().getChild(child) : Optional.absent(); } private Optional metadataFromData(@Nonnull final PathArgument child, final Version modVersion) { @@ -162,12 +164,12 @@ final class ModifiedNode extends NodeModification implements StoreTreeNode currentMetadata = findOriginalMetadata(child, modVersion); - final ModifiedNode newlyCreated = new ModifiedNode(child, currentMetadata, childPolicy); + final ModifiedNode newlyCreated = new ModifiedNode(child, currentMetadata, childOper.getChildPolicy()); if (operation == LogicalOperation.MERGE && value != null) { /* * We are attempting to modify a previously-unmodified part of a MERGE node. If the @@ -190,7 +192,7 @@ final class ModifiedNode extends NodeModification implements StoreTreeNode> childData = ((NormalizedNodeContainer)value).getChild(child); if (childData.isPresent()) { - newlyCreated.updateValue(LogicalOperation.MERGE, childData.get()); + childOper.mergeIntoModifiedNode(newlyCreated, childData.get(), modVersion); } } @@ -346,4 +348,14 @@ final class ModifiedNode extends NodeModification implements StoreTreeNode current, final TreeNode node) { + this.validatedOp = Preconditions.checkNotNull(op); + this.validatedCurrent = Preconditions.checkNotNull(current); + this.validatedNode = Preconditions.checkNotNull(node); + } + + TreeNode getValidatedNode(final SchemaAwareApplyOperation op, final Optional current) { + return op.equals(validatedOp) && current.equals(validatedCurrent) ? validatedNode : null; + } }