1 package org.opendaylight.controller.sal.utils;
4 * Represents the return object of the osgi service interfaces function calls.
5 * It contains a code {@code StatusCode} representing the result of the call
6 * and a string which describes a failure reason (if any) in human readable form.
13 * Generates an instance of the Status class.
15 * @param errorCode The status code. If passed as null, code will be
16 * stored as {@code StatusCode.UNDEFINED}
17 * @param description The human readable description of the status. If passed
18 * as null, description will be inferred by the code
20 public Status(StatusCode errorCode, String description) {
21 this.code = (errorCode != null)? errorCode : StatusCode.UNDEFINED;
22 this.description = (description != null)? description : this.code.toString();
26 * Returns the status code
27 * @return the {@code StatusCode} representing the status code
29 public StatusCode getCode() {
34 * Returns a human readable description of the failure if any
35 * @return a string representing the reason of failure
37 public String getDescription() {
42 * Tells whether the status is successful
43 * @return true if the Status code is {@code StatusCode.SUCCESS}
45 public boolean isSuccess() {
46 return code == StatusCode.SUCCESS;
50 public String toString() {
51 return code + ": " + description;
55 public int hashCode() {
58 result = prime * result + ((code == null) ? 0 : code.hashCode());
63 public boolean equals(Object obj) {
68 if (getClass() != obj.getClass())
70 Status other = (Status) obj;
71 if (code != other.code)