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.collect.ForwardingObject;
12 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
14 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
15 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
17 abstract class DelegatingWriteCursorStrategy extends ForwardingObject implements WriteCursorStrategy {
20 protected abstract DOMDataTreeWriteCursor delegate();
23 * Returns strategy to be used on child nodes. Default implementation is to reuse same instance.
25 * @return Strategy to be used for child nodes.
27 protected DelegatingWriteCursorStrategy childStrategy() {
32 public WriteCursorStrategy enter(final PathArgument arg) {
33 delegate().enter(arg);
34 return childStrategy();
38 public void delete(final PathArgument arg) {
39 delegate().delete(arg);
43 public void merge(final PathArgument arg, final NormalizedNode<?, ?> data) {
44 delegate().merge(arg, data);
48 public void write(final PathArgument arg, final NormalizedNode<?, ?> data) {
49 delegate().write(arg, data);
53 public void mergeToCurrent(final NormalizedNodeContainer<?, ?, ?> data) {
54 for (NormalizedNode<?, ?> child : data.getValue()) {
55 delegate().merge(child.getIdentifier(), child);
60 public void writeToCurrent(final NormalizedNodeContainer<?, ?, ?> data) {
61 for (NormalizedNode<?, ?> child : data.getValue()) {
62 delegate().write(child.getIdentifier(), child);
67 * Operation performed to exit current logical level, default implementation calls
68 * {@link DOMDataTreeWriteCursor#exit()} on underlaying cursor.
71 * Subclasses may override this to customize exit strategy.