1 package org.opendaylight.controller.sal.restconf.impl;
4 import java.util.Collections;
6 import org.opendaylight.yangtools.yang.common.QName;
7 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
8 import org.opendaylight.yangtools.yang.data.api.Node;
9 import org.opendaylight.yangtools.yang.data.impl.NodeFactory;
11 import com.google.common.base.Preconditions;
13 public final class EmptyNodeWrapper implements NodeWrapper<Node<?>>, Node<Void> {
15 private Node<?> unwrapped;
17 private String localName;
18 private URI namespace;
21 private boolean composite;
23 public boolean isComposite() {
27 public void setComposite(boolean composite) {
28 this.composite = composite;
31 public EmptyNodeWrapper(URI namespace, String localName) {
32 this.localName = Preconditions.checkNotNull(localName);
33 this.namespace = namespace;
37 public void setQname(QName name) {
38 Preconditions.checkState(unwrapped == null, "Cannot change the object, due to data inconsistencies.");
43 public QName getQname() {
48 public String getLocalName() {
49 if (unwrapped != null) {
50 return unwrapped.getNodeType().getLocalName();
56 public URI getNamespace() {
57 if (unwrapped != null) {
58 return unwrapped.getNodeType().getNamespace();
64 public void setNamespace(URI namespace) {
65 Preconditions.checkState(unwrapped == null, "Cannot change the object, due to data inconsistencies.");
66 this.namespace = namespace;
70 public boolean isChangeAllowed() {
71 return unwrapped == null ? true : false;
75 public Node<?> unwrap() {
76 if (unwrapped == null) {
78 Preconditions.checkNotNull(namespace);
79 name = new QName(namespace, localName);
82 unwrapped = NodeFactory.createImmutableCompositeNode(name, null, Collections.<Node<?>>emptyList(),null);
84 unwrapped = NodeFactory.createImmutableSimpleNode(name, null, null);
94 public QName getNodeType() {
95 return unwrap().getNodeType();
99 public CompositeNode getParent() {
100 return unwrap().getParent();
104 public Void getValue() {
109 public QName getKey() {
110 return unwrap().getKey();
114 public Void setValue(Void value) {