Added NodeWithValue class for leaf-list type in instance-identifier type 91/4791/1
authorMartin Sunal <msunal@cisco.com>
Sun, 26 Jan 2014 10:41:46 +0000 (11:41 +0100)
committerMartin Sunal <msunal@cisco.com>
Sun, 26 Jan 2014 10:41:46 +0000 (11:41 +0100)
Signed-off-by: Martin Sunal <msunal@cisco.com>
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/InstanceIdentifier.java

index 92f3adb3e87975ba49bfdf7d207fcd6fe14638f2..b0cce8f2be844817c3b05edd57bb91680a8a9f88 100644 (file)
@@ -206,6 +206,68 @@ public class InstanceIdentifier implements Path<InstanceIdentifier>, Immutable,
         public String toString() {\r
             return nodeType + "[" + keyValues + "]";\r
         }\r
+    }
+
+    public static final class NodeWithValue implements PathArgument {
+
+        /**
+         * 
+         */
+        private static final long serialVersionUID = -3637456085341738431L;
+
+        private final QName nodeType;
+        private final Object value;
+
+        public NodeWithValue(QName node, Object value) {
+            this.nodeType = node;
+            this.value = value;
+        }
+
+        @Override
+        public QName getNodeType() {
+            return nodeType;
+        }
+
+        public Object getValue() {
+            return value;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((value == null) ? 0 : value.hashCode());
+            result = prime * result + ((nodeType == null) ? 0 : nodeType.hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj)
+                return true;
+            if (obj == null)
+                return false;
+            if (getClass() != obj.getClass())
+                return false;
+            NodeWithValue other = (NodeWithValue) obj;
+            if (value == null) {
+                if (other.value != null)
+                    return false;
+            } else if (!value.equals(other.value))
+                return false;
+            if (nodeType == null) {
+                if (other.nodeType != null)
+                    return false;
+            } else if (!nodeType.equals(other.nodeType))
+                return false;
+            return true;
+        }
+
+        @Override
+        public String toString() {
+            return nodeType + "[" + value + "]";
+        }
+
     }\r
 \r
     private static class BuilderImpl implements InstanceIdentifierBuilder {\r