BUG-869: removed useless null check from DataValidationException.checkListKey 35/10435/2
authorMartin Vitez <mvitez@cisco.com>
Thu, 28 Aug 2014 09:46:25 +0000 (11:46 +0200)
committerMartin Vitez <mvitez@cisco.com>
Thu, 28 Aug 2014 11:27:12 +0000 (13:27 +0200)
Null check is useless because

1. it is already performed in call to overloaded checkListKey
2. value is already dereferenced and if it were null a NullPointerException would have occurred

Expression 'if (isLegal == false)' simplified to 'if (!isLegal)'.

Change-Id: I7bf332e99e35d283726e439caf1d2a39a17df932
Signed-off-by: Martin Vitez <mvitez@cisco.com>
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/valid/DataValidationException.java

index 493c6ceec0055628c3ac77aa4a469edab5b542e6..7a6627eb5e444dddfd9dd385def15f2fcd8cbc24 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid;
 
 import java.util.Map;
 import java.util.Set;
-
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
@@ -26,26 +25,26 @@ public class DataValidationException extends RuntimeException {
 
     public static void checkLegalChild(final boolean isLegal, final YangInstanceIdentifier.PathArgument child, final DataNodeContainer schema,
             final Set<QName> childNodes, final Set<YangInstanceIdentifier.AugmentationIdentifier> augments) {
-        if (isLegal == false) {
+        if (!isLegal) {
             throw new IllegalChildException(child, schema, childNodes, augments);
         }
     }
 
     public static void checkLegalChild(final boolean isLegal, final YangInstanceIdentifier.PathArgument child, final DataSchemaNode schema,
             final Set<QName> childNodes) {
-        if (isLegal == false) {
+        if (!isLegal) {
             throw new IllegalChildException(child, schema, childNodes);
         }
     }
 
     public static void checkLegalChild(final boolean isLegal, final YangInstanceIdentifier.PathArgument child, final ChoiceNode schema) {
-        if (isLegal == false) {
+        if (!isLegal) {
             throw new IllegalChildException(child, schema);
         }
     }
 
     public static void checkLegalData(final boolean isLegal, final String messageTemplate, final Object... messageAttrs) {
-        if (isLegal == false) {
+        if (!isLegal) {
             throw new DataValidationException(String.format(messageTemplate, messageAttrs));
         }
     }
@@ -56,9 +55,6 @@ public class DataValidationException extends RuntimeException {
 
         Object expectedValue = nodeId.getKeyValues().get(keyQName);
         Object actualValue = childNode.getValue();
-        if (childNode == null) {
-            throw new IllegalListKeyException(keyQName, nodeId, actualValue, expectedValue);
-        }
     }
 
     public static void checkListKey(final DataContainerChild<?, ?> childNode, final QName keyQName, final YangInstanceIdentifier.NodeIdentifierWithPredicates nodeId) {