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.restconf.rest.services.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.netconf.sal.restconf.impl.RestconfDocumentedException;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
18 import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
19 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
21 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
22 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
23 import org.opendaylight.yangtools.yang.model.api.Status;
24 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
25 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
26 import org.opendaylight.yangtools.yang.model.api.UsesNode;
29 * Special case only use by GET restconf/operations (since moment of old Yang
30 * parser and old yang model API removal) to build and use fake container for
34 class ContainerSchemaNodeImpl implements ContainerSchemaNode {
36 List<DataSchemaNode> child = new ArrayList<>();
37 private final QName qname = QName.create(ModuleImpl.moduleQName, "operations");
38 private final SchemaPath path = SchemaPath.create(true, this.qname);
41 public Set<TypeDefinition<?>> getTypeDefinitions() {
42 throw new UnsupportedOperationException("Not supported.");
46 public Collection<DataSchemaNode> getChildNodes() {
51 public Set<GroupingDefinition> getGroupings() {
52 throw new UnsupportedOperationException("Not supported.");
56 public DataSchemaNode getDataChildByName(final QName name) {
57 for (final DataSchemaNode node : this.child) {
58 if (node.getQName().equals(name)) {
62 throw new RestconfDocumentedException(name + " is not in child of " + this.qname);
66 public Set<UsesNode> getUses() {
67 throw new UnsupportedOperationException("Not supported.");
71 public Set<AugmentationSchema> getAvailableAugmentations() {
72 return new HashSet<>();
76 public boolean isAugmenting() {
81 public boolean isAddedByUses() {
86 public boolean isConfiguration() {
91 public ConstraintDefinition getConstraints() {
92 throw new UnsupportedOperationException("Not supported.");
96 public QName getQName() {
101 public SchemaPath getPath() {
106 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
107 throw new UnsupportedOperationException("Not supported.");
111 public String getDescription() {
112 throw new UnsupportedOperationException("Not supported.");
116 public String getReference() {
117 throw new UnsupportedOperationException("Not supported.");
121 public Status getStatus() {
122 throw new UnsupportedOperationException("Not supported.");
126 public boolean isPresenceContainer() {
127 throw new UnsupportedOperationException("Not supported.");
131 * Adding new schema node to this container
134 * - fake schema leaf node
136 public void addNodeChild(final DataSchemaNode fakeLeaf) {
137 this.child.add(fakeLeaf);