2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.sal.restconf.impl;
10 import com.google.common.base.Preconditions;
12 import java.util.Collections;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
15 import org.opendaylight.yangtools.yang.data.api.Node;
16 import org.opendaylight.yangtools.yang.data.impl.NodeFactory;
18 public final class EmptyNodeWrapper implements NodeWrapper<Node<?>>, Node<Void> {
20 private Node<?> unwrapped;
22 private String localName;
23 private URI namespace;
26 private boolean composite;
28 public boolean isComposite() {
32 public void setComposite(final boolean composite) {
33 this.composite = composite;
36 public EmptyNodeWrapper(final URI namespace, final String localName) {
37 this.localName = Preconditions.checkNotNull(localName);
38 this.namespace = namespace;
42 public void setQname(final QName name) {
43 Preconditions.checkState(unwrapped == null, "Cannot change the object, due to data inconsistencies.");
48 public QName getQname() {
53 public String getLocalName() {
54 if (unwrapped != null) {
55 return unwrapped.getNodeType().getLocalName();
61 public URI getNamespace() {
62 if (unwrapped != null) {
63 return unwrapped.getNodeType().getNamespace();
69 public void setNamespace(final URI namespace) {
70 Preconditions.checkState(unwrapped == null, "Cannot change the object, due to data inconsistencies.");
71 this.namespace = namespace;
75 public boolean isChangeAllowed() {
76 return unwrapped == null ? true : false;
80 public Node<?> unwrap() {
81 if (unwrapped == null) {
83 Preconditions.checkNotNull(namespace);
84 name = new QName(namespace, localName);
87 unwrapped = NodeFactory.createImmutableCompositeNode(name, null, Collections.<Node<?>> emptyList(),
90 unwrapped = NodeFactory.createImmutableSimpleNode(name, null, null);
100 public QName getNodeType() {
101 return unwrap().getNodeType();
106 public CompositeNode getParent() {
107 return unwrap().getParent();
111 public Void getValue() {
116 public QName getKey() {
117 return unwrap().getKey();
121 public Void setValue(final Void value) {