ded653b7e1b696a91ec116fd8220bc78d16fd7dd
[netconf.git] / restconf / restconf-common / src / main / java / org / opendaylight / restconf / common / util / OperationsLeafSchemaNode.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 java.util.Collection;
11 import java.util.Collections;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
15 import org.opendaylight.yangtools.yang.model.api.MustDefinition;
16 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
17 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
18 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
19 import org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement;
20 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
21
22 final class OperationsLeafSchemaNode extends AbstractOperationDataSchemaNode implements LeafSchemaNode {
23     private final QName qname;
24
25     OperationsLeafSchemaNode(final RpcDefinition rpc) {
26         this.qname = rpc.getQName();
27     }
28
29     @Override
30     public TypeDefinition<?> getType() {
31         return BaseTypes.emptyType();
32     }
33
34     @Override
35     public QName getQName() {
36         return qname;
37     }
38
39     @Override
40     @Deprecated
41     public SchemaPath getPath() {
42         return OperationsContainerSchemaNode.PATH.createChild(getQName());
43     }
44
45     @Override
46     public boolean isMandatory() {
47         // This leaf has to be present
48         return true;
49     }
50
51     @Override
52     public Collection<@NonNull MustDefinition> getMustConstraints() {
53         return Collections.emptySet();
54     }
55
56     @Override
57     public LeafEffectiveStatement asEffectiveStatement() {
58         throw new UnsupportedOperationException();
59     }
60 }