Package uk.ac.starlink.topcat
Class Outcome
java.lang.Object
uk.ac.starlink.topcat.Outcome
Indicates the outcome of a user-initiated action, typically an
activation action.
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.
- Since:
- 10 Apr 2018
- Author:
- Mark Taylor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Outcome
Returns a failure outcome with a given message.static Outcome
Returns a failure outcome based on an exception.Returns the message text associated with this outcome.boolean
Indicates whether the action was successful or not.static Outcome
success()
Returns a success outcome with no message.static Outcome
Returns a success outcome with a given message.
-
Constructor Details
-
Outcome
Constructor.- Parameters:
isSuccess
- true for success, false for errormessage
- one-line outcome message
-
-
Method Details
-
getMessage
Returns the message text associated with this outcome.- Returns:
- outcome message
-
isSuccess
public boolean isSuccess()Indicates whether the action was successful or not.- Returns:
- true for success, false for failure
-
success
Returns a success outcome with no message. -
success
Returns a success outcome with a given message.- Parameters:
message
- one-line message describing successful outcome
-
failure
Returns a failure outcome with a given message.- Parameters:
message
- one-line message giving reason for failure
-
failure
Returns a failure outcome based on an exception.- Parameters:
error
- error that caused the action failure; if at all possible the message should explain in user-friendy terms what went wrong
-