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.spi.shard;
11 import com.google.common.annotations.Beta;
12 import com.google.common.collect.ForwardingObject;
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;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
19 * Delegating implementation of a {@link WriteCursorStrategy}.
22 public abstract class DelegatingWriteCursorStrategy extends ForwardingObject implements WriteCursorStrategy {
25 protected abstract DOMDataTreeWriteCursor delegate();
28 * Returns strategy to be used on child nodes. Default implementation is to reuse same instance.
30 * @return Strategy to be used for child nodes.
32 protected DelegatingWriteCursorStrategy childStrategy() {
37 public WriteCursorStrategy enter(final PathArgument arg) {
38 delegate().enter(arg);
39 return childStrategy();
43 public void delete(final PathArgument arg) {
44 delegate().delete(arg);
48 public void merge(final PathArgument arg, final NormalizedNode<?, ?> data) {
49 delegate().merge(arg, data);
53 public void write(final PathArgument arg, final NormalizedNode<?, ?> data) {
54 delegate().write(arg, data);
58 public void mergeToCurrent(final NormalizedNodeContainer<?, ?, ?> data) {
59 for (NormalizedNode<?, ?> child : data.getValue()) {
60 delegate().merge(child.getIdentifier(), child);
65 public void writeToCurrent(final NormalizedNodeContainer<?, ?, ?> data) {
66 for (NormalizedNode<?, ?> child : data.getValue()) {
67 delegate().write(child.getIdentifier(), child);
72 * Operation performed to exit current logical level, default implementation calls
73 * {@link DOMDataTreeWriteCursor#exit()} on underlaying cursor.
76 * Subclasses may override this to customize exit strategy.