2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.mdsal.dom.store.inmemory;
11 import com.google.common.base.Preconditions;
12 import java.util.ArrayDeque;
13 import java.util.Deque;
14 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
18 class ShardDataModificationCursor implements DOMDataTreeWriteCursor {
20 private final Deque<WriteCursorStrategy> stack = new ArrayDeque<>();
21 private final InmemoryDOMDataTreeShardWriteTransaction parent;
23 ShardDataModificationCursor(final ShardDataModification root, final InmemoryDOMDataTreeShardWriteTransaction parent) {
24 stack.push(root.createOperation(null));
25 this.parent = Preconditions.checkNotNull(parent);
29 public void enter(final PathArgument child) {
30 WriteCursorStrategy nextOp = getCurrent().enter(child);
34 private WriteCursorStrategy getCurrent() {
39 public void enter(final PathArgument... path) {
40 for (PathArgument pathArgument : path) {
46 public void enter(final Iterable<PathArgument> path) {
47 for (PathArgument pathArgument : path) {
54 WriteCursorStrategy op = stack.pop();
59 public void exit(final int depth) {
60 for (int i = 0; i < depth; i++) {
67 parent.cursorClosed();
71 public void delete(final PathArgument child) {
72 getCurrent().delete(child);
76 public void merge(final PathArgument child, final NormalizedNode<?, ?> data) {
77 getCurrent().merge(child, data);
81 public void write(final PathArgument child, final NormalizedNode<?, ?> data) {
82 getCurrent().write(child, data);