BUG-3823 : fixed Sonar issues for PCEP/programming
[bgpcep.git] / pcep / spi / src / main / java / org / opendaylight / protocol / pcep / spi / ObjectHeaderImpl.java
index f2d2d61726add756dc398be90b7b3349c2ba913f..65724a6832508c2ffb0207e6d907d2056064efae 100644 (file)
@@ -15,10 +15,10 @@ import org.opendaylight.yangtools.yang.binding.DataContainer;
  */
 public class ObjectHeaderImpl implements ObjectHeader {
 
-    private final boolean processed;
-    private final boolean ignored;
+    private final Boolean processed;
+    private final Boolean ignored;
 
-    public ObjectHeaderImpl(final boolean processed, final boolean ignore) {
+    public ObjectHeaderImpl(final Boolean processed, final Boolean ignore) {
         this.processed = processed;
         this.ignored = ignore;
     }
@@ -54,8 +54,8 @@ public class ObjectHeaderImpl implements ObjectHeader {
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + (this.ignored ? 1231 : 1237);
-        result = prime * result + (this.processed ? 1231 : 1237);
+        result = prime * result + ((this.ignored == null) ? 0 : this.ignored.hashCode());
+        result = prime * result + ((this.processed == null) ? 0 : this.processed.hashCode());
         return result;
     }
 
@@ -64,17 +64,22 @@ public class ObjectHeaderImpl implements ObjectHeader {
         if (this == obj) {
             return true;
         }
-        if (obj == null) {
-            return false;
-        }
-        if (this.getClass() != obj.getClass()) {
+        if (obj == null || getClass() != obj.getClass()) {
             return false;
         }
         final ObjectHeaderImpl other = (ObjectHeaderImpl) obj;
-        if (this.ignored != other.ignored) {
+        if (this.ignored == null) {
+            if (other.ignored != null) {
+                return false;
+            }
+        } else if (!this.ignored.equals(other.ignored)) {
             return false;
         }
-        if (this.processed != other.processed) {
+        if (this.processed == null) {
+            if (other.processed != null) {
+                return false;
+            }
+        } else if (!this.processed.equals(other.processed)) {
             return false;
         }
         return true;