Use ImmutableMap instead of Collections.emptyMap()
[mdsal.git] / dom / mdsal-dom-inmemory-datastore / src / main / java / org / opendaylight / mdsal / dom / store / inmemory / 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
9 package org.opendaylight.mdsal.dom.store.inmemory;
10
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 final class WriteableSubshardBoundaryNode extends WriteableModificationNode {
18
19     private final ForeignShardModificationContext boundary;
20
21     private WriteableSubshardBoundaryNode(final ForeignShardModificationContext boundary) {
22         this.boundary = Preconditions.checkNotNull(boundary);
23     }
24
25     public static WriteableSubshardBoundaryNode from(final ForeignShardModificationContext value) {
26         return new WriteableSubshardBoundaryNode(value);
27     }
28
29     @Override
30     public PathArgument getIdentifier() {
31         return boundary.getIdentifier().getRootIdentifier().getLastPathArgument();
32     }
33
34     @Override
35     WriteCursorStrategy createOperation(final DOMDataTreeWriteCursor parentCursor) {
36         return new DelegatingWriteCursorStrategy() {
37             @Override
38             public void exit() {
39                 parentCursor.exit();
40             }
41
42             @Override
43             protected DelegatingWriteCursorStrategy childStrategy() {
44                 return new DelegatingWriteCursorStrategy() {
45                     @Override
46                     protected DOMDataTreeWriteCursor delegate() {
47                         return boundary.getCursor();
48                     }
49                 };
50             }
51
52             @Override
53             protected DOMDataTreeWriteCursor delegate() {
54                 return boundary.getCursor();
55             }
56         };
57     }
58
59     @Override
60     WriteableModificationNode getChild(final PathArgument node) {
61         // Another level of nesting should be taken care of by underlying cursor.
62         return null;
63     }
64
65     @Override
66     void markDeleted() {
67         // FIXME: Should we delete all data or disconnect?
68     }
69
70     @Override
71     Map<PathArgument, WriteableModificationNode> getChildrenWithSubshards() {
72         return ImmutableMap.of();
73     }
74 }