Do not generate 'isFoo()' methods
[mdsal.git] / dom / mdsal-dom-spi / src / main / java / org / opendaylight / mdsal / dom / spi / shard / DelegatingWriteCursorStrategy.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.mdsal.dom.spi.shard;
9
10 import com.google.common.annotations.Beta;
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;
16
17 /**
18  * Delegating implementation of a {@link WriteCursorStrategy}.
19  *
20  * @deprecated This interface is scheduled for removal in the next major release.
21  */
22 @Deprecated(forRemoval = true)
23 @Beta
24 public abstract class DelegatingWriteCursorStrategy extends ForwardingObject implements WriteCursorStrategy {
25
26     @Override
27     protected abstract DOMDataTreeWriteCursor delegate();
28
29     /**
30      * Returns strategy to be used on child nodes. Default implementation is to reuse same instance.
31      *
32      * @return Strategy to be used for child nodes.
33      */
34     protected DelegatingWriteCursorStrategy childStrategy() {
35         return this;
36     }
37
38     @Override
39     public WriteCursorStrategy enter(final PathArgument arg) {
40         delegate().enter(arg);
41         return childStrategy();
42     }
43
44     @Override
45     public void delete(final PathArgument arg) {
46         delegate().delete(arg);
47     }
48
49     @Override
50     public void merge(final PathArgument arg, final NormalizedNode<?, ?> data) {
51         delegate().merge(arg, data);
52     }
53
54     @Override
55     public void write(final PathArgument arg, final NormalizedNode<?, ?> data) {
56         delegate().write(arg, data);
57     }
58
59     @Override
60     public void mergeToCurrent(final NormalizedNodeContainer<?, ?, ?> data) {
61         for (NormalizedNode<?, ?> child : data.getValue()) {
62             delegate().merge(child.getIdentifier(), child);
63         }
64     }
65
66     @Override
67     public void writeToCurrent(final NormalizedNodeContainer<?, ?, ?> data) {
68         for (NormalizedNode<?, ?> child : data.getValue()) {
69             delegate().write(child.getIdentifier(), child);
70         }
71     }
72
73     /**
74      * Operation performed to exit current logical level, default implementation calls
75      * {@link DOMDataTreeWriteCursor#exit()} on underlaying cursor.
76      *
77      *<p>
78      * Subclasses may override this to customize exit strategy.
79      *
80      */
81     @Override
82     public void exit() {
83         delegate().exit();
84     }
85 }