BUG-582: eliminate useless null checks 76/7776/1
authorRobert Varga <rovarga@cisco.com>
Fri, 6 Jun 2014 12:19:37 +0000 (14:19 +0200)
committerRobert Varga <rovarga@cisco.com>
Fri, 6 Jun 2014 12:43:37 +0000 (14:43 +0200)
These checks are not useful, as the fields checked have been verified to
be non-null. Also optimizes AbstractPathArgument.hashCode() by directly
referring to the type -- we assume storing the PathArgument alongside
with the class is not going to be used very often.

Change-Id: Id3f4d67819de8462801823880e482a480843fa1e
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java

index be97e1fd47034df5e1adb80859b5fa9ca9e38466..b1de340ebe6e8656fdeb59d977435533e37b583b 100644 (file)
@@ -510,10 +510,7 @@ public class InstanceIdentifier<T extends DataObject> implements Path<InstanceId
 
         @Override
         public int hashCode() {
-            final int prime = 31;
-            int result = 1;
-            result = prime * result + ((type == null) ? 0 : type.hashCode());
-            return result;
+            return type.hashCode();
         }
 
         @Override
@@ -528,14 +525,7 @@ public class InstanceIdentifier<T extends DataObject> implements Path<InstanceId
                 return false;
             }
             final AbstractPathArgument<?> other = (AbstractPathArgument<?>) obj;
-            if (type == null) {
-                if (other.type != null) {
-                    return false;
-                }
-            } else if (!type.equals(other.type)) {
-                return false;
-            }
-            return true;
+            return type.equals(other.type);
         }
     }