Split Restconf implementations (draft02 and RFC) - move
[netconf.git] / restconf / restconf-nb-bierman02 / src / main / java / org / opendaylight / restconf / base / services / impl / FakeContainerSchemaNode.java
1 /*
2  * Copyright (c) 2016 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.restconf.base.services.impl;
9
10 import com.google.common.collect.ImmutableList;
11 import java.util.Collection;
12 import java.util.HashSet;
13 import java.util.List;
14 import java.util.Set;
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;
28
29 /**
30  * Special case only use by GET restconf/operations (since moment of old Yang parser and old yang model API
31  * removal) to build and use fake container for module.
32  *
33  * @deprecated move to splitted module restconf-nb-rfc8040
34  */
35 @Deprecated
36 class FakeContainerSchemaNode implements ContainerSchemaNode {
37     static final SchemaPath PATH =
38             SchemaPath.create(true, QName.create(FakeRestconfModule.QNAME, "operations").intern());
39
40     private final Collection<DataSchemaNode> children;
41
42     FakeContainerSchemaNode(final Collection<LeafSchemaNode> children) {
43         this.children = ImmutableList.copyOf(children);
44     }
45
46     @Override
47     public Set<TypeDefinition<?>> getTypeDefinitions() {
48         throw new UnsupportedOperationException("Not supported.");
49     }
50
51     @Override
52     public Collection<DataSchemaNode> getChildNodes() {
53         return this.children;
54     }
55
56     @Override
57     public Set<GroupingDefinition> getGroupings() {
58         throw new UnsupportedOperationException("Not supported.");
59     }
60
61     @Override
62     public DataSchemaNode getDataChildByName(final QName name) {
63         for (final DataSchemaNode node : this.children) {
64             if (node.getQName().equals(name)) {
65                 return node;
66             }
67         }
68         throw new RestconfDocumentedException(name + " is not in child of " + PATH.getLastComponent());
69     }
70
71     @Override
72     public Set<UsesNode> getUses() {
73         throw new UnsupportedOperationException("Not supported.");
74     }
75
76     @Override
77     public Set<AugmentationSchema> getAvailableAugmentations() {
78         return new HashSet<>();
79     }
80
81     @Override
82     public boolean isAugmenting() {
83         return false;
84     }
85
86     @Override
87     public boolean isAddedByUses() {
88         return false;
89     }
90
91     @Override
92     public boolean isConfiguration() {
93         return false;
94     }
95
96     @Override
97     public ConstraintDefinition getConstraints() {
98         throw new UnsupportedOperationException("Not supported.");
99     }
100
101     @Override
102     public QName getQName() {
103         return PATH.getLastComponent();
104     }
105
106     @Override
107     public SchemaPath getPath() {
108         return PATH;
109     }
110
111     @Override
112     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
113         throw new UnsupportedOperationException("Not supported.");
114     }
115
116     @Override
117     public String getDescription() {
118         throw new UnsupportedOperationException("Not supported.");
119     }
120
121     @Override
122     public String getReference() {
123         throw new UnsupportedOperationException("Not supported.");
124     }
125
126     @Override
127     public Status getStatus() {
128         throw new UnsupportedOperationException("Not supported.");
129     }
130
131     @Override
132     public boolean isPresenceContainer() {
133         throw new UnsupportedOperationException("Not supported.");
134     }
135 }