From c6cae2fe5e4ea8ce5699de0c6daf869bbbe1c6f7 Mon Sep 17 00:00:00 2001 From: Martin Sunal Date: Sun, 26 Jan 2014 11:41:46 +0100 Subject: [PATCH 1/1] Added NodeWithValue class for leaf-list type in instance-identifier type Signed-off-by: Martin Sunal --- .../yang/data/api/InstanceIdentifier.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/InstanceIdentifier.java b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/InstanceIdentifier.java index 92f3adb3e8..b0cce8f2be 100644 --- a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/InstanceIdentifier.java +++ b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/InstanceIdentifier.java @@ -206,6 +206,68 @@ public class InstanceIdentifier implements Path, Immutable, public String toString() { return nodeType + "[" + keyValues + "]"; } + } + + 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 + "]"; + } + } private static class BuilderImpl implements InstanceIdentifierBuilder { -- 2.36.6