*/
package org.opendaylight.yangtools.yang.data.impl;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableMap;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.ModifyAction;
-import org.opendaylight.yangtools.yang.data.api.Node;
-import org.opendaylight.yangtools.yang.data.api.NodeModification;
+import org.opendaylight.yangtools.yang.data.api.*;
+
+import java.net.URI;
+import java.util.Map;
/**
* @author michal.rehak
* @param <T>
* type of node value
- *
+ *
*/
public abstract class AbstractNodeTO<T> implements Node<T>, NodeModification {
private T value;
private ModifyAction modifyAction;
+ // Only for Serialization use
+ public AbstractNodeTO(){
+
+ }
+
/**
* @param qname
* @param parent
* @param value
*/
public AbstractNodeTO(QName qname, CompositeNode parent, T value) {
- this.qName = qname;
- this.parent = parent;
- this.value = value;
+ this(qname, parent, value, null);
}
/**
* @param value
* the value to set
*/
- protected void setValue(T value) {
+ public T setValue(T value) {
+ T oldValue = this.value;
this.value = value;
+ return oldValue;
}
@Override
return out.toString();
}
+
+ @Override
+ public final QName getKey() {
+ return getNodeType();
+ }
+
/* */
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((modifyAction == null) ? 0 : modifyAction.hashCode());
result = prime * result + ((qName == null) ? 0 : qName.hashCode());
result = prime * result + ((value == null) ? 0 : value.hashCode());
return result % 2;
}
@SuppressWarnings("unchecked")
AbstractNodeTO<T> other = (AbstractNodeTO<T>) obj;
- if (modifyAction != other.modifyAction) {
- return false;
- }
if (parent == null) {
if (other.parent != null) {
return false;
}
/* */
+
+ //Serialization related
+
+ protected final void init(QName qName, CompositeNode parent, T value, ModifyAction modifyAction){
+ this.qName = qName;
+ this.modifyAction = modifyAction;
+ this.parent = parent;
+ this.value = value;
+ }
}