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
8 package org.opendaylight.mdsal.dom.spi.shard;
10 import com.google.common.annotations.Beta;
11 import java.util.ArrayDeque;
12 import java.util.Deque;
13 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
15 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
18 * Abstract base class for {@link DOMDataTreeWriteCursor} implementations.
20 * @param <M> Modification type
22 * @deprecated This interface is scheduled for removal in the next major release.
25 @Deprecated(forRemoval = true)
26 public abstract class AbstractDataModificationCursor<M> implements DOMDataTreeWriteCursor {
27 private final Deque<WriteCursorStrategy> stack = new ArrayDeque<>();
29 public AbstractDataModificationCursor(final M root) {
30 stack.push(getRootOperation(root));
33 protected abstract WriteCursorStrategy getRootOperation(M root);
35 private WriteCursorStrategy getCurrent() {
40 public void enter(final PathArgument child) {
41 WriteCursorStrategy nextOp = getCurrent().enter(child);
46 public void enter(final PathArgument... path) {
47 for (PathArgument pathArgument : path) {
53 public void enter(final Iterable<PathArgument> path) {
54 for (PathArgument pathArgument : path) {
61 WriteCursorStrategy op = stack.pop();
66 public void exit(final int depth) {
67 for (int i = 0; i < depth; i++) {
73 public abstract void close();
76 public void delete(final PathArgument child) {
77 getCurrent().delete(child);
81 public void merge(final PathArgument child, final NormalizedNode<?, ?> data) {
82 getCurrent().merge(child, data);
86 public void write(final PathArgument child, final NormalizedNode<?, ?> data) {
87 getCurrent().write(child, data);