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

©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.