X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fsal%2Fyang-prototype%2Fyang%2Fyang-data-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fyang%2Fdata%2Fimpl%2FAbstractNodeTO.java;h=3385700c46b0041f1b017d7fd6e837c1d2e49e42;hp=cc4dfee5a5d4df5a16514af98165fa0da5d369b5;hb=970fb91c60c15a9b57e078f81aab7dde903addb9;hpb=eab494c3b4460508405f9b6e5cab2969b3546a6b diff --git a/opendaylight/sal/yang-prototype/yang/yang-data-impl/src/main/java/org/opendaylight/controller/yang/data/impl/AbstractNodeTO.java b/opendaylight/sal/yang-prototype/yang/yang-data-impl/src/main/java/org/opendaylight/controller/yang/data/impl/AbstractNodeTO.java old mode 100755 new mode 100644 index cc4dfee5a5..3385700c46 --- a/opendaylight/sal/yang-prototype/yang/yang-data-impl/src/main/java/org/opendaylight/controller/yang/data/impl/AbstractNodeTO.java +++ b/opendaylight/sal/yang-prototype/yang/yang-data-impl/src/main/java/org/opendaylight/controller/yang/data/impl/AbstractNodeTO.java @@ -9,7 +9,9 @@ package org.opendaylight.controller.yang.data.impl; import org.opendaylight.controller.yang.common.QName; import org.opendaylight.controller.yang.data.api.CompositeNode; +import org.opendaylight.controller.yang.data.api.ModifyAction; import org.opendaylight.controller.yang.data.api.Node; +import org.opendaylight.controller.yang.data.api.NodeModification; /** * @author michal.rehak @@ -17,12 +19,13 @@ import org.opendaylight.controller.yang.data.api.Node; * type of node value * */ -public abstract class AbstractNodeTO implements Node { +public abstract class AbstractNodeTO implements Node, NodeModification { private QName qName; private CompositeNode parent; private T value; - + private ModifyAction modifyAction; + /** * @param qname * @param parent @@ -33,6 +36,19 @@ public abstract class AbstractNodeTO implements Node { this.parent = parent; this.value = value; } + + /** + * @param qname + * @param parent + * @param value + * @param modifyAction + */ + public AbstractNodeTO(QName qname, CompositeNode parent, T value, ModifyAction modifyAction) { + this.qName = qname; + this.parent = parent; + this.value = value; + this.modifyAction = modifyAction; + } @Override public QName getNodeType() { @@ -42,7 +58,7 @@ public abstract class AbstractNodeTO implements Node { /** * @return the qName */ - protected QName getQName() { + public QName getQName() { return qName; } @@ -69,4 +85,76 @@ public abstract class AbstractNodeTO implements Node { public T getValue() { return value; } + + /** + * @return modification action + * @see org.opendaylight.controller.yang.data.impl.NodeModificationSupport#getModificationAction() + */ + @Override + public ModifyAction getModificationAction() { + return modifyAction; + } + + /** + * @param modifyAction + * the modifyAction to set + */ + protected void setModificationAction(ModifyAction modifyAction) { + this.modifyAction = modifyAction; + } + + @Override + public String toString() { + StringBuffer out = new StringBuffer(); + out.append(String.format("Node[%s], qName[%s], modify[%s]", + getClass().getSimpleName(), getQName().getLocalName(), + getModificationAction() == null ? "n/a" : getModificationAction())); + return out.toString(); + } + + /* */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((modifyAction == null) ? 0 : modifyAction.hashCode()); +// result = prime * result + ((parent == null) ? 0 : parent.hashCode()); + result = prime * result + ((qName == null) ? 0 : qName.hashCode()); + result = prime * result + ((value == null) ? 0 : value.hashCode()); + return result % 2; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + @SuppressWarnings("unchecked") + AbstractNodeTO other = (AbstractNodeTO) obj; + if (modifyAction != other.modifyAction) + return false; + if (parent == null) { + if (other.parent != null) + return false; + } else if (other.parent == null) { + return false; + } + if (qName == null) { + if (other.qName != null) + return false; + } else if (!qName.equals(other.qName)) + return false; + if (value == null) { + if (other.value != null) + return false; + } else if (!value.equals(other.value)) + return false; + return true; + } + /* */ + }