X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fsal%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Futils%2FStatus.java;h=0387f72f382da08bc1ec395e73158d11545e253c;hb=edf5bfcee83c750853253ccfd991ba7000f5f65b;hp=2fbb3e55f841eb80db4f5397b3913683cd77c5cc;hpb=59cc8f34c24d81a8890a94c11dedd4b21caa0adf;p=controller.git diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/Status.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/Status.java index 2fbb3e55f8..0387f72f38 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/Status.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/Status.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -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; @@ -23,7 +26,7 @@ public class Status { * for internal API2 function calls. This constructor allows to specify, * beside the Status Code, a custom human readable description to add more * information about the status. - * + * * @param errorCode * The status code. If passed as null, code will be stored as * {@code StatusCode.UNDEFINED} @@ -42,7 +45,7 @@ public class Status { * Generates an instance of the Status class based on the passed StatusCode * only. The description field of the Status object will be inferred by the * status code. - * + * * @param errorCode * The status code. If passed as null, code will be stored as * {@code StatusCode.UNDEFINED} @@ -59,7 +62,7 @@ public class Status { * asynchronous call. It is supposed to be created by the underlying * infrastructure only when it was successful in allocating the asynchronous * request id, hence caller should expect StatusCode to be successful. - * + * * @param errorCode * The status code. If passed as null, code will be stored as * {@code StatusCode.UNDEFINED} @@ -76,7 +79,7 @@ public class Status { /** * Returns the status code - * + * * @return the {@code StatusCode} representing the status code */ public StatusCode getCode() { @@ -85,7 +88,7 @@ public class Status { /** * Returns a human readable description of the failure if any - * + * * @return a string representing the reason of failure */ public String getDescription() { @@ -94,18 +97,18 @@ public class Status { /** * Tells whether the status is successful - * + * * @return true if the Status code is {@code StatusCode.SUCCESS} */ public boolean isSuccess() { - return code == StatusCode.SUCCESS; + return code == StatusCode.SUCCESS || code == StatusCode.CREATED; } /** * Return the request id assigned by underlying infrastructure in case of * asynchronous request. In case of synchronous requests, the returned id * is expected to be 0 - * + * * @return The request id assigned for this asynchronous request */ public long getRequestId() { @@ -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; } }