X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=restconf%2Fsal-rest-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Frestconf%2Fbase%2Fservices%2Fimpl%2FFakeContainerSchemaNode.java;fp=restconf%2Fsal-rest-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fsal%2Frestconf%2Fimpl%2FContainerSchemaNodeImpl.java;h=4519507bf1c8304e81b9737b5306857df8dfa2ff;hb=2436ec5e97f51fdaf38d4024acfd2794ba8eb653;hp=3f25fb9c0b22a4beea15c86513841af9a5093ed0;hpb=b345bb647b410ce35d1c0eb2b86d5958c83ba947;p=netconf.git diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/ContainerSchemaNodeImpl.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/base/services/impl/FakeContainerSchemaNode.java similarity index 77% rename from restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/ContainerSchemaNodeImpl.java rename to restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/base/services/impl/FakeContainerSchemaNode.java index 3f25fb9c0b..4519507bf1 100644 --- a/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/ContainerSchemaNodeImpl.java +++ b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/base/services/impl/FakeContainerSchemaNode.java @@ -5,19 +5,21 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.netconf.sal.restconf.impl; +package org.opendaylight.restconf.base.services.impl; -import java.util.ArrayList; +import com.google.common.collect.ImmutableList; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; +import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.AugmentationSchema; import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.GroupingDefinition; +import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.api.Status; import org.opendaylight.yangtools.yang.model.api.TypeDefinition; @@ -25,14 +27,18 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; import org.opendaylight.yangtools.yang.model.api.UsesNode; /** - * Special case only use by GET restconf/operations (since moment of pre-Beryllium Yang - * parser and yang model API removal) to build and use fake container for module + * Special case only use by GET restconf/operations (since moment of old Yang + * parser and old yang model API removal) to build and use fake container for + * module. */ -class ContainerSchemaNodeImpl implements ContainerSchemaNode { +class FakeContainerSchemaNode implements ContainerSchemaNode { + static final SchemaPath PATH = SchemaPath.create(true, QName.create(FakeRestconfModule.QNAME, "operations").intern()); - List child = new ArrayList<>(); - private final QName qname = QName.create(ModuleImpl.moduleQName, "operations"); - private final SchemaPath path = SchemaPath.create(true, this.qname); + private final Collection children; + + FakeContainerSchemaNode(final Collection children) { + this.children = ImmutableList.copyOf(children); + } @Override public Set> getTypeDefinitions() { @@ -41,7 +47,7 @@ class ContainerSchemaNodeImpl implements ContainerSchemaNode { @Override public Collection getChildNodes() { - return this.child; + return this.children; } @Override @@ -51,12 +57,12 @@ class ContainerSchemaNodeImpl implements ContainerSchemaNode { @Override public DataSchemaNode getDataChildByName(final QName name) { - for (final DataSchemaNode node : this.child) { + for (final DataSchemaNode node : this.children) { if (node.getQName().equals(name)) { return node; } } - throw new RestconfDocumentedException(name + " is not in child of " + this.qname); + throw new RestconfDocumentedException(name + " is not in child of " + PATH.getLastComponent()); } @Override @@ -91,12 +97,12 @@ class ContainerSchemaNodeImpl implements ContainerSchemaNode { @Override public QName getQName() { - return this.qname; + return PATH.getLastComponent(); } @Override public SchemaPath getPath() { - return this.path; + return PATH; } @Override @@ -123,14 +129,4 @@ class ContainerSchemaNodeImpl implements ContainerSchemaNode { public boolean isPresenceContainer() { throw new UnsupportedOperationException("Not supported."); } - - /** - * Adding new schema node to this container - * - * @param fakeLeaf - * - fake schema leaf node - */ - public void addNodeChild(final DataSchemaNode fakeLeaf) { - this.child.add(fakeLeaf); - } }