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 org.opendaylight.yangtools.yang.common.QName;
13 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
14 import org.opendaylight.yangtools.yang.data.api.ModifyAction;
15 import org.opendaylight.yangtools.yang.data.api.MutableSimpleNode;
16 import org.opendaylight.yangtools.yang.data.api.SimpleNode;
17 import org.opendaylight.yangtools.yang.data.impl.NodeFactory;
20 * @deprecated class will be removed in Lithium release
23 public final class SimpleNodeWrapper implements NodeWrapper<SimpleNode<?>>, SimpleNode<Object> {
25 private SimpleNode<Object> simpleNode;
27 private String localName;
29 private URI namespace;
32 public SimpleNodeWrapper(final String localName, final Object value) {
33 this.localName = Preconditions.checkNotNull(localName);
37 public SimpleNodeWrapper(final URI namespace, final String localName, final Object value) {
38 this(localName, value);
39 this.namespace = namespace;
43 public void setQname(final QName name) {
44 Preconditions.checkState(simpleNode == null, "Cannot change the object, due to data inconsistencies.");
49 public QName getQname() {
54 public String getLocalName() {
55 if (simpleNode != null) {
56 return simpleNode.getNodeType().getLocalName();
62 public URI getNamespace() {
63 if (simpleNode != null) {
64 return simpleNode.getNodeType().getNamespace();
70 public void setNamespace(final URI namespace) {
71 Preconditions.checkState(simpleNode == null, "Cannot change the object, due to data inconsistencies.");
72 this.namespace = namespace;
76 public boolean isChangeAllowed() {
77 return simpleNode == null ? true : false;
81 public SimpleNode<Object> unwrap() {
82 if (simpleNode == null) {
84 Preconditions.checkNotNull(namespace);
85 name = new QName(namespace, localName);
87 simpleNode = NodeFactory.createImmutableSimpleNode(name, null, value);
98 public QName getNodeType() {
99 return unwrap().getNodeType();
104 public CompositeNode getParent() {
105 return unwrap().getParent();
109 public Object getValue() {
110 return unwrap().getValue();
115 public ModifyAction getModificationAction() {
116 return unwrap().getModificationAction();
120 public MutableSimpleNode<Object> asMutable() {
121 return unwrap().asMutable();
125 public QName getKey() {
126 return unwrap().getKey();
130 public Object setValue(final Object value) {
131 return unwrap().setValue(value);