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.base.services.impl;
10 import com.google.common.collect.ImmutableList;
11 import java.util.Collection;
12 import java.util.HashSet;
13 import java.util.List;
15 import org.opendaylight.restconf.common.errors.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.LeafSchemaNode;
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;
30 * Special case only use by GET restconf/operations (since moment of old Yang
31 * parser and old yang model API removal) to build and use fake container for
34 class FakeContainerSchemaNode implements ContainerSchemaNode {
35 static final SchemaPath PATH =
36 SchemaPath.create(true, QName.create(FakeRestconfModule.QNAME, "operations").intern());
38 private final Collection<DataSchemaNode> children;
40 FakeContainerSchemaNode(final Collection<LeafSchemaNode> children) {
41 this.children = ImmutableList.copyOf(children);
45 public Set<TypeDefinition<?>> getTypeDefinitions() {
46 throw new UnsupportedOperationException("Not supported.");
50 public Collection<DataSchemaNode> getChildNodes() {
55 public Set<GroupingDefinition> getGroupings() {
56 throw new UnsupportedOperationException("Not supported.");
60 public DataSchemaNode getDataChildByName(final QName name) {
61 for (final DataSchemaNode node : this.children) {
62 if (node.getQName().equals(name)) {
66 throw new RestconfDocumentedException(name + " is not in child of " + PATH.getLastComponent());
70 public Set<UsesNode> getUses() {
71 throw new UnsupportedOperationException("Not supported.");
75 public Set<AugmentationSchema> getAvailableAugmentations() {
76 return new HashSet<>();
80 public boolean isAugmenting() {
85 public boolean isAddedByUses() {
90 public boolean isConfiguration() {
95 public ConstraintDefinition getConstraints() {
96 throw new UnsupportedOperationException("Not supported.");
100 public QName getQName() {
101 return PATH.getLastComponent();
105 public SchemaPath getPath() {
110 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
111 throw new UnsupportedOperationException("Not supported.");
115 public String getDescription() {
116 throw new UnsupportedOperationException("Not supported.");
120 public String getReference() {
121 throw new UnsupportedOperationException("Not supported.");
125 public Status getStatus() {
126 throw new UnsupportedOperationException("Not supported.");
130 public boolean isPresenceContainer() {
131 throw new UnsupportedOperationException("Not supported.");