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