3f881c388b00e772a669818511105b0e6059ba92
[mdsal.git] / dom / mdsal-dom-spi / src / main / java / org / opendaylight / mdsal / dom / spi / shard / WriteableSubshardBoundaryNode.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 static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.Beta;
13 import com.google.common.collect.ImmutableMap;
14 import java.util.Map;
15 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
17
18 /**
19  * Writable node that is located at a boundary to a subshard.
20  *
21  * @deprecated This interface is scheduled for removal in the next major release.
22  */
23 @Deprecated(forRemoval = true)
24 @Beta
25 public class WriteableSubshardBoundaryNode extends WriteableModificationNode {
26
27     private final ForeignShardModificationContext boundary;
28
29     WriteableSubshardBoundaryNode(final ForeignShardModificationContext boundary) {
30         this.boundary = requireNonNull(boundary);
31     }
32
33     public static WriteableSubshardBoundaryNode from(final ForeignShardModificationContext value) {
34         return new WriteableSubshardBoundaryNode(value);
35     }
36
37     @Override
38     public PathArgument getIdentifier() {
39         return boundary.getIdentifier().getRootIdentifier().getLastPathArgument();
40     }
41
42     @Override
43     public WriteCursorStrategy createOperation(final DOMDataTreeWriteCursor parentCursor) {
44         return new DelegatingWriteCursorStrategy() {
45             @Override
46             public void exit() {
47                 parentCursor.exit();
48             }
49
50             @Override
51             protected DelegatingWriteCursorStrategy childStrategy() {
52                 return new DelegatingWriteCursorStrategy() {
53                     @Override
54                     protected DOMDataTreeWriteCursor delegate() {
55                         return boundary.getCursor();
56                     }
57                 };
58             }
59
60             @Override
61             protected DOMDataTreeWriteCursor delegate() {
62                 return boundary.getCursor();
63             }
64         };
65     }
66
67     @Override
68     public WriteableModificationNode getChild(final PathArgument node) {
69         // Another level of nesting should be taken care of by underlying cursor.
70         return null;
71     }
72
73     @Override
74     public void markDeleted() {
75         // FIXME: Should we delete all data or disconnect?
76     }
77
78     @Override
79     public Map<PathArgument, WriteableModificationNode> getChildrenWithSubshards() {
80         return ImmutableMap.of();
81     }
82 }