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