Merge "BUG-2329 Add test for anyxmls inside rpc resonse for netcfon-connector"
[controller.git] / opendaylight / sal / api / src / main / java / org / opendaylight / controller / sal / utils / Status.java
index 1d7ce224b5620f438947eeb29139309cd865b7f2..0387f72f382da08bc1ec395e73158d11545e253c 100644 (file)
@@ -8,12 +8,15 @@
 
 package org.opendaylight.controller.sal.utils;
 
+import java.io.Serializable;
+
 /**
  * Represents the return object of the osgi service interfaces function calls.
  * It contains a code {@code StatusCode} representing the result of the call and
  * a string which describes a failure reason (if any) in human readable form.
  */
-public class Status {
+public class Status implements Serializable {
+    private static final long serialVersionUID = 0L;
     private StatusCode code;
     private String description;
     private long requestId;
@@ -98,7 +101,7 @@ public class Status {
      * @return true if the Status code is {@code StatusCode.SUCCESS}
      */
     public boolean isSuccess() {
-        return code == StatusCode.SUCCESS;
+        return code == StatusCode.SUCCESS || code == StatusCode.CREATED;
     }
 
     /**
@@ -121,21 +124,25 @@ public class Status {
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((code == null) ? 0 : code.calculateConsistentHashCode());
         return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         Status other = (Status) obj;
-        if (code != other.code)
+        if (code != other.code) {
             return false;
+        }
         return true;
     }
 }