public class Outcome
extends java.lang.Object
As well as a success/failure flag, instances of this class contain a message to be directed to the user who initiated the action. In case of success this is a short indication of what happened, and in case of failure it is an error message. The context of the action may be assumed, and does not need to be repeated here. The message should be concise (one line). In case of success, if there's really nothing to say, a null message is permitted.
Modifier | Constructor | Description |
---|---|---|
protected |
Outcome(boolean isSuccess,
java.lang.String message) |
Constructor.
|
Modifier and Type | Method | Description |
---|---|---|
static Outcome |
failure(java.lang.String message) |
Returns a failure outcome with a given message.
|
static Outcome |
failure(java.lang.Throwable error) |
Returns a failure outcome based on an exception.
|
java.lang.String |
getMessage() |
Returns the message text associated with this outcome.
|
boolean |
isSuccess() |
Indicates whether the action was successful or not.
|
static Outcome |
success() |
Returns a success outcome with no message.
|
static Outcome |
success(java.lang.String message) |
Returns a success outcome with a given message.
|
protected Outcome(boolean isSuccess, java.lang.String message)
isSuccess
- true for success, false for errormessage
- one-line outcome messagepublic java.lang.String getMessage()
public boolean isSuccess()
public static Outcome success()
public static Outcome success(java.lang.String message)
message
- one-line message describing successful outcomepublic static Outcome failure(java.lang.String message)
message
- one-line message giving reason for failurepublic static Outcome failure(java.lang.Throwable error)
error
- error that caused the action failure;
if at all possible the message should explain
in user-friendy terms what went wrongCopyright © 2003-2018 CCLRC: Council for the Central Laboratory of the Research Councils. All Rights Reserved.