From: Martin Sunal Date: Sun, 26 Jan 2014 10:41:46 +0000 (+0100) Subject: Added NodeWithValue class for leaf-list type in instance-identifier type X-Git-Tag: yangtools-0.6.0~21 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=c6cae2fe5e4ea8ce5699de0c6daf869bbbe1c6f7;hp=48da3a4411749845f8c58e93effef14e68fd925e;p=yangtools.git Added NodeWithValue class for leaf-list type in instance-identifier type Signed-off-by: Martin Sunal --- 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 {