Adjust to yangtools-2.0.0/odlparent-3.0.0 changes
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / services / simple / impl / FakeLeafSchemaNode.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.nb.rfc8040.services.simple.impl;
9
10 import com.google.common.collect.ImmutableList;
11 import java.util.Collection;
12 import java.util.List;
13 import java.util.Optional;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
16 import org.opendaylight.yangtools.yang.model.api.MustDefinition;
17 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
18 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
19 import org.opendaylight.yangtools.yang.model.api.Status;
20 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
21 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
22 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
23
24 /**
25  * Special case only use by GET restconf/operations (since moment of old Yang
26  * parser and old yang model API removal) to build and use fake leaf like child
27  * in container.
28  */
29 final class FakeLeafSchemaNode implements LeafSchemaNode {
30
31     private final SchemaPath path;
32
33     /**
34      * Base values for fake leaf schema node.
35      *
36      * @param qname
37      *             qname
38      */
39     FakeLeafSchemaNode(final QName qname) {
40         this.path = FakeContainerSchemaNode.PATH.createChild(qname);
41     }
42
43     @Override
44     public boolean isAugmenting() {
45         return true;
46     }
47
48     @Override
49     public boolean isAddedByUses() {
50         return false;
51     }
52
53     @Override
54     public boolean isConfiguration() {
55         return false;
56     }
57
58     @Override
59     public QName getQName() {
60         return path.getLastComponent();
61     }
62
63     @Override
64     public SchemaPath getPath() {
65         return path;
66     }
67
68     @Override
69     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
70         throw new UnsupportedOperationException("Not supported.");
71     }
72
73     @Override
74     public Optional<String> getDescription() {
75         throw new UnsupportedOperationException("Not supported operations.");
76     }
77
78     @Override
79     public Optional<String> getReference() {
80         throw new UnsupportedOperationException("Not supported.");
81     }
82
83     @Override
84     public Status getStatus() {
85         throw new UnsupportedOperationException("Not supported.");
86     }
87
88     @Override
89     public TypeDefinition<?> getType() {
90         return BaseTypes.emptyType();
91     }
92
93     @Override
94     public Optional<RevisionAwareXPath> getWhenCondition() {
95         return Optional.empty();
96     }
97
98     @Override
99     public boolean isMandatory() {
100         throw new UnsupportedOperationException("Not supported.");
101     }
102
103     @Override
104     public Collection<MustDefinition> getMustConstraints() {
105         return ImmutableList.of();
106     }
107 }