2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.netconf.sal.restconf.impl;
10 import java.util.ArrayList;
11 import java.util.Collection;
12 import java.util.HashSet;
13 import java.util.List;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
17 import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
18 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
21 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
22 import org.opendaylight.yangtools.yang.model.api.Status;
23 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
24 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
25 import org.opendaylight.yangtools.yang.model.api.UsesNode;
28 * Special case only use by GET restconf/operations (since moment of pre-Beryllium Yang
29 * parser and yang model API removal) to build and use fake container for module
31 class ContainerSchemaNodeImpl implements ContainerSchemaNode {
33 List<DataSchemaNode> child = new ArrayList<>();
34 private final QName qname = QName.create(ModuleImpl.moduleQName, "operations");
35 private final SchemaPath path = SchemaPath.create(true, this.qname);
38 public Set<TypeDefinition<?>> getTypeDefinitions() {
39 throw new UnsupportedOperationException("Not supported.");
43 public Collection<DataSchemaNode> getChildNodes() {
48 public Set<GroupingDefinition> getGroupings() {
49 throw new UnsupportedOperationException("Not supported.");
53 public DataSchemaNode getDataChildByName(final QName name) {
54 for (final DataSchemaNode node : this.child) {
55 if (node.getQName().equals(name)) {
59 throw new RestconfDocumentedException(name + " is not in child of " + this.qname);
63 public DataSchemaNode getDataChildByName(final String name) {
64 for (final DataSchemaNode node : this.child) {
65 if (node.getQName().getLocalName().equals(name)) {
69 throw new RestconfDocumentedException(name + " is not in child of " + this.qname);
73 public Set<UsesNode> getUses() {
74 throw new UnsupportedOperationException("Not supported.");
78 public Set<AugmentationSchema> getAvailableAugmentations() {
79 return new HashSet<>();
83 public boolean isAugmenting() {
88 public boolean isAddedByUses() {
93 public boolean isConfiguration() {
98 public ConstraintDefinition getConstraints() {
99 throw new UnsupportedOperationException("Not supported.");
103 public QName getQName() {
108 public SchemaPath getPath() {
113 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
114 throw new UnsupportedOperationException("Not supported.");
118 public String getDescription() {
119 throw new UnsupportedOperationException("Not supported.");
123 public String getReference() {
124 throw new UnsupportedOperationException("Not supported.");
128 public Status getStatus() {
129 throw new UnsupportedOperationException("Not supported.");
133 public boolean isPresenceContainer() {
134 throw new UnsupportedOperationException("Not supported.");
138 * Adding new schema node to this container
141 * - fake schema leaf node
143 public void addNodeChild(final DataSchemaNode fakeLeaf) {
144 this.child.add(fakeLeaf);