467db9b4bf3bb2ee1155176e10d9cc2db7b0a1f9
[netconf.git] / restconf / restconf-common / src / main / java / org / opendaylight / restconf / common / util / OperationsRestconfModule.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.common.util;
9
10 import static java.util.Objects.requireNonNull;
11
12 import java.util.Collection;
13 import java.util.List;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.common.QNameModule;
17 import org.opendaylight.yangtools.yang.common.XMLNamespace;
18 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
20
21 final class OperationsRestconfModule extends AbstractOperationsModule {
22     // There is no need to intern this nor add a revision, as we are providing the corresponding context anyway
23     static final @NonNull QNameModule NAMESPACE =
24             QNameModule.create(XMLNamespace.of("urn:ietf:params:xml:ns:yang:ietf-restconf"));
25
26     private final OperationsContainerSchemaNode operations;
27
28     OperationsRestconfModule(final OperationsContainerSchemaNode operations) {
29         this.operations = requireNonNull(operations);
30     }
31
32     @Override
33     public String getName() {
34         return "ietf-restconf";
35     }
36
37     @Override
38     public QNameModule getQNameModule() {
39         return NAMESPACE;
40     }
41
42     @Override
43     public String getPrefix() {
44         return "rc";
45     }
46
47     @Override
48     public Collection<DataSchemaNode> getChildNodes() {
49         return List.of(operations);
50     }
51
52     @Override
53     public DataSchemaNode dataChildByName(final QName name) {
54         return operations.getQName().equals(requireNonNull(name)) ? operations : null;
55     }
56
57     @Override
58     public List<EffectiveStatement<?, ?>> effectiveSubstatements() {
59         // This is not accurate, but works for now
60         return List.of();
61     }
62 }