a0d231f87059f1e29a44b61defb7e4d86aaba004
[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.TypeDefinition;
18 import org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement;
19 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
20
21 final class OperationsLeafSchemaNode extends AbstractOperationDataSchemaNode implements LeafSchemaNode {
22     private final QName qname;
23
24     OperationsLeafSchemaNode(final RpcDefinition rpc) {
25         qname = rpc.getQName();
26     }
27
28     @Override
29     public TypeDefinition<?> getType() {
30         return BaseTypes.emptyType();
31     }
32
33     @Override
34     public QName getQName() {
35         return qname;
36     }
37
38     @Override
39     public boolean isMandatory() {
40         // This leaf has to be present
41         return true;
42     }
43
44     @Override
45     public Collection<@NonNull MustDefinition> getMustConstraints() {
46         return Collections.emptySet();
47     }
48
49     @Override
50     public LeafEffectiveStatement asEffectiveStatement() {
51         throw new UnsupportedOperationException();
52     }
53 }