Make NodeWithValue generic 66/26866/10
authorRobert Varga <rovarga@cisco.com>
Sat, 22 Aug 2015 09:17:02 +0000 (11:17 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 13 Jan 2016 13:46:17 +0000 (13:46 +0000)
Retaining the type of contained value is useful in various places, which
means we don't have to add an explicit cast.

Change-Id: Ibf3b16fd7b3348730f3efb3e284a345e69003e30
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/YangInstanceIdentifier.java

index 9944d741e66cd64a99e61c82393646e8c9dae6a3..06760528ea9e33d61589542624dbe672dda69f64 100644 (file)
@@ -575,17 +575,17 @@ public abstract class YangInstanceIdentifier implements Path<YangInstanceIdentif
      * Simple path argument identifying a {@link LeafSetEntryNode} leaf
      * overall data tree.
      */
-    public static final class NodeWithValue extends AbstractPathArgument {
+    public static final class NodeWithValue<T> extends AbstractPathArgument {
         private static final long serialVersionUID = -3637456085341738431L;
 
-        private final Object value;
+        private final T value;
 
-        public NodeWithValue(final QName node, final Object value) {
+        public NodeWithValue(final QName node, final T value) {
             super(node);
             this.value = value;
         }
 
-        public Object getValue() {
+        public T getValue() {
             return value;
         }
 
@@ -593,7 +593,7 @@ public abstract class YangInstanceIdentifier implements Path<YangInstanceIdentif
         protected int hashCodeImpl() {
             final int prime = 31;
             int result = super.hashCodeImpl();
-            result = prime * result + ((value == null) ? 0 : YangInstanceIdentifier.hashCode(value));
+            result = prime * result + YangInstanceIdentifier.hashCode(value);
             return result;
         }
 
@@ -602,7 +602,7 @@ public abstract class YangInstanceIdentifier implements Path<YangInstanceIdentif
             if (!super.equals(obj)) {
                 return false;
             }
-            final NodeWithValue other = (NodeWithValue) obj;
+            final NodeWithValue<?> other = (NodeWithValue<?>) obj;
             return Objects.deepEquals(value, other.value);
         }