Reduce cyclomatic complexity 68/35868/1
authorRobert Varga <rovarga@cisco.com>
Mon, 7 Mar 2016 10:44:10 +0000 (11:44 +0100)
committerRobert Varga <rovarga@cisco.com>
Mon, 7 Mar 2016 10:44:10 +0000 (11:44 +0100)
Reduces number of branches in methods.

Change-Id: I79e2b453dd82d0baf1ac3b8c75dea31c7fca4523
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/MustDefinitionImpl.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/PatternConstraintImpl.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/RangeConstraintImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/UnknownEffectiveStatementImpl.java

index d361fa98c643bdcb73643c52349b35d23a9bd423..90b64767a32c07e326206f61a55c48799e28167d 100644 (file)
@@ -84,7 +84,7 @@ public final class MustDefinitionImpl implements MustDefinition {
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + Objects.hashCode(mustStr);
+        result = prime * result + mustStr.hashCode();
         result = prime * result + Objects.hashCode(description);
         result = prime * result + Objects.hashCode(reference);
         return result;
@@ -95,28 +95,16 @@ public final class MustDefinitionImpl implements MustDefinition {
         if (this == obj) {
             return true;
         }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
+        if (!(obj instanceof MustDefinitionImpl)) {
             return false;
         }
         final MustDefinitionImpl other = (MustDefinitionImpl) obj;
-        if (!Objects.equals(mustStr, other.mustStr)) {
-            return false;
-        }
-        if (!Objects.equals(description, other.description)) {
-            return false;
-        }
-        if (!Objects.equals(reference, other.reference)) {
-            return false;
-        }
-        return true;
+        return mustStr.equals(other.mustStr) && Objects.equals(description, other.description)
+                && Objects.equals(reference, other.reference);
     }
 
     @Override
     public String toString() {
         return mustStr;
     }
-
 }
index eecc2a01f5295f45bc14ed966c9b61740a94a50a..4b33f20772f14134d06c1a83e11d8d95441f001e 100644 (file)
@@ -89,29 +89,13 @@ final class PatternConstraintImpl implements PatternConstraint, Immutable {
         if (this == obj) {
             return true;
         }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
+        if (!(obj instanceof PatternConstraintImpl)) {
             return false;
         }
         final PatternConstraintImpl other = (PatternConstraintImpl) obj;
-        if (!Objects.equals(description, other.description)) {
-            return false;
-        }
-        if (!Objects.equals(errorAppTag, other.errorAppTag)) {
-            return false;
-        }
-        if (!Objects.equals(errorMessage, other.errorMessage)) {
-            return false;
-        }
-        if (!Objects.equals(reference, other.reference)) {
-            return false;
-        }
-        if (!Objects.equals(regex, other.regex)) {
-            return false;
-        }
-        return true;
+        return Objects.equals(description, other.description) && Objects.equals(errorAppTag, other.errorAppTag)
+                && Objects.equals(errorMessage, other.errorMessage) && Objects.equals(reference, other.reference)
+                && Objects.equals(regex, other.regex);
     }
 
     @Override
index f8db0870528abaa1cd85efdf79da137b9f359d3d..2bf3b32ddb8a31a2c2fbb9c309e353e8da7771d1 100644 (file)
@@ -96,26 +96,12 @@ final class RangeConstraintImpl implements RangeConstraint, Immutable {
         if (this == obj) {
             return true;
         }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
+        if (!(obj instanceof RangeConstraintImpl)) {
             return false;
         }
         final RangeConstraintImpl other = (RangeConstraintImpl) obj;
-        if (!Objects.equals(description, other.description)) {
-            return false;
-        }
-        if (!Objects.equals(max, other.max)) {
-            return false;
-        }
-        if (!Objects.equals(min, other.min)) {
-            return false;
-        }
-        if (!Objects.equals(reference, other.reference)) {
-            return false;
-        }
-        return true;
+        return Objects.equals(description, other.description) && Objects.equals(max, other.max)
+                && Objects.equals(min, other.min) && Objects.equals(reference, other.reference);
     }
 
     @Override
index 2ee3f8283dc7c087ddd69b8f0fc3ffca30199039..6e197561dc67f9b5ae6b387c21c3d983af5b3fe7 100644 (file)
@@ -67,25 +67,12 @@ public final class UnknownEffectiveStatementImpl extends UnknownEffectiveStateme
         if (this == obj) {
             return true;
         }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
+        if (!(obj instanceof UnknownEffectiveStatementImpl)) {
             return false;
         }
         UnknownEffectiveStatementImpl other = (UnknownEffectiveStatementImpl) obj;
-        if (!Objects.equals(maybeQNameArgument, other.maybeQNameArgument)) {
-            return false;
-        }
-        if (!Objects.equals(path, other.path)) {
-            return false;
-        }
-        if (!Objects.equals(getNodeType(), other.getNodeType())) {
-            return false;
-        }
-        if (!Objects.equals(getNodeParameter(), other.getNodeParameter())) {
-            return false;
-        }
-        return true;
+        return Objects.equals(maybeQNameArgument, other.maybeQNameArgument) && Objects.equals(path, other.path)
+                && Objects.equals(getNodeType(), other.getNodeType())
+                && Objects.equals(getNodeParameter(), other.getNodeParameter());
     }
 }