bd075d0606b08f3f94982e32d18ecdb468b9830a
[controller.git] / opendaylight / md-sal / sal-netconf-connector / src / main / java / org / opendaylight / controller / sal / connect / netconf / util / NodeContainerProxy.java
1 /*
2  * Copyright (c) 2014 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.controller.sal.connect.netconf.util;
9
10 import com.google.common.base.Preconditions;
11 import com.google.common.collect.Maps;
12 import com.google.common.collect.Sets;
13 import java.util.Collections;
14 import java.util.List;
15 import java.util.Map;
16 import java.util.Set;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
19 import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
20 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
21 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
22 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
23 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
24 import org.opendaylight.yangtools.yang.model.api.Status;
25 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
26 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
27 import org.opendaylight.yangtools.yang.model.api.UsesNode;
28
29 class NodeContainerProxy implements ContainerSchemaNode {
30
31     private final Map<QName, DataSchemaNode> childNodes;
32     private final QName qName;
33
34     public NodeContainerProxy(final QName qName, final Map<QName, DataSchemaNode> childNodes) {
35         this.childNodes = Preconditions.checkNotNull(childNodes, "childNodes");
36         this.qName = Preconditions.checkNotNull(qName, "qName");
37     }
38
39     public NodeContainerProxy(final QName qName, final Set<DataSchemaNode> childNodes) {
40         this(qName, asMap(childNodes));
41     }
42
43     private static Map<QName, DataSchemaNode> asMap(final Set<DataSchemaNode> childNodes) {
44         final Map<QName, DataSchemaNode> mapped = Maps.newHashMap();
45         for (final DataSchemaNode childNode : childNodes) {
46             mapped.put(childNode.getQName(), childNode);
47         }
48         return mapped;
49     }
50
51     @Override
52     public Set<TypeDefinition<?>> getTypeDefinitions() {
53         return Collections.emptySet();
54     }
55
56     @Override
57     public Set<DataSchemaNode> getChildNodes() {
58         return Sets.newHashSet(childNodes.values());
59     }
60
61     @Override
62     public Set<GroupingDefinition> getGroupings() {
63         return Collections.emptySet();
64     }
65
66     @Override
67     public DataSchemaNode getDataChildByName(final QName qName) {
68         return childNodes.get(qName);
69     }
70
71     @Override
72     public DataSchemaNode getDataChildByName(final String s) {
73         throw new UnsupportedOperationException();
74     }
75
76     @Override
77     public Set<UsesNode> getUses() {
78         return Collections.emptySet();
79     }
80
81     @Override
82     public boolean isPresenceContainer() {
83         throw new UnsupportedOperationException();
84     }
85
86     @Override
87     public Set<AugmentationSchema> getAvailableAugmentations() {
88         throw new UnsupportedOperationException();
89     }
90
91     @Override
92     public boolean isAugmenting() {
93         throw new UnsupportedOperationException();
94     }
95
96     @Override
97     public boolean isAddedByUses() {
98         throw new UnsupportedOperationException();
99     }
100
101     @Override
102     public boolean isConfiguration() {
103         throw new UnsupportedOperationException();
104     }
105
106     @Override
107     public ConstraintDefinition getConstraints() {
108         throw new UnsupportedOperationException();
109     }
110
111     @Override
112     public QName getQName() {
113         return qName;
114     }
115
116     @Override
117     public SchemaPath getPath() {
118         throw new UnsupportedOperationException();
119     }
120
121     @Override
122     public String getDescription() {
123         throw new UnsupportedOperationException();
124     }
125
126     @Override
127     public String getReference() {
128         throw new UnsupportedOperationException();
129     }
130
131     @Override
132     public Status getStatus() {
133         throw new UnsupportedOperationException();
134     }
135
136     @Override
137     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
138         return Collections.emptyList();
139     }
140 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.