Class Status
- java.lang.Object
-
- ch.systemsx.cisd.common.exceptions.Status
-
- Direct Known Subclasses:
StatusWithResult
public class Status extends java.lang.Object
A class that holds the information about the status of an operation. To be used whenever a failure of an operation is signalled back via a return value rather than an exception.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Status(StatusFlag flag, java.lang.String message)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Status
createError()
static Status
createError(boolean retriable)
Create an error.static Status
createError(boolean retriable, java.lang.String message)
static Status
createError(java.lang.String message)
static Status
createError(java.lang.String messageTemplate, java.lang.Object... args)
static Status
createRetriableError()
static Status
createRetriableError(java.lang.String message)
static Status
createRetriableError(java.lang.String messageTemplate, java.lang.Object... args)
boolean
equals(java.lang.Object obj)
protected static StatusFlag
getErrorFlag(boolean retriable)
StatusFlag
getFlag()
int
hashCode()
boolean
isError()
boolean
isNonRetriableError()
boolean
isOK()
boolean
isRetriableError()
java.lang.String
toString()
java.lang.String
tryGetErrorMessage()
-
-
-
Field Detail
-
OK
public static final Status OK
The status indicating that the operation went fine.
-
-
Constructor Detail
-
Status
protected Status(StatusFlag flag, java.lang.String message)
-
-
Method Detail
-
createError
public static Status createError(boolean retriable)
Create an error.- Parameters:
retriable
- Iftrue
, the error will be marked 'retriable'.
-
createError
public static Status createError(boolean retriable, java.lang.String message)
-
createError
public static Status createError()
-
createError
public static Status createError(java.lang.String message)
-
createError
public static Status createError(java.lang.String messageTemplate, java.lang.Object... args)
-
createRetriableError
public static Status createRetriableError()
-
createRetriableError
public static Status createRetriableError(java.lang.String message)
-
createRetriableError
public static Status createRetriableError(java.lang.String messageTemplate, java.lang.Object... args)
-
getErrorFlag
protected static StatusFlag getErrorFlag(boolean retriable)
-
getFlag
public StatusFlag getFlag()
- Returns:
- The status flag of the operation.
-
isOK
public final boolean isOK()
- Returns:
true
if this status represents an OK status.
-
isError
public final boolean isError()
- Returns:
true
if this status represents an error.
-
isRetriableError
public final boolean isRetriableError()
- Returns:
true
if this status represents an error where it makes sense to retry the operation.
-
isNonRetriableError
public final boolean isNonRetriableError()
- Returns:
true
if this status represents an error where it does not make sense to retry the operation.
-
tryGetErrorMessage
public java.lang.String tryGetErrorMessage()
- Returns:
- The error message of the operation if
getFlag() != OK
(can be empty), ornull
otherwise.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-