public class Outcome extends 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 and Description |
---|---|
protected |
Outcome(boolean isSuccess,
String message)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static Outcome |
failure(String message)
Returns a failure outcome with a given message.
|
static Outcome |
failure(Throwable error)
Returns a failure outcome based on an exception.
|
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(String message)
Returns a success outcome with a given message.
|
protected Outcome(boolean isSuccess, String message)
isSuccess
- true for success, false for errormessage
- one-line outcome messagepublic String getMessage()
public boolean isSuccess()
public static Outcome success()
public static Outcome success(String message)
message
- one-line message describing successful outcomepublic static Outcome failure(String message)
message
- one-line message giving reason for failureCopyright © 2003-2025 CCLRC: Council for the Central Laboratory of the Research Councils. All Rights Reserved.