uk.ac.starlink.topcat
Class Outcome

java.lang.Object
  extended by uk.ac.starlink.topcat.Outcome

public class Outcome
extends Object

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
protected Outcome(boolean isSuccess, String message)
          Constructor.
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Outcome

protected Outcome(boolean isSuccess,
                  String message)
Constructor.

Parameters:
isSuccess - true for success, false for error
message - one-line outcome message
Method Detail

getMessage

public String 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

public static Outcome success()
Returns a success outcome with no message.


success

public static Outcome success(String message)
Returns a success outcome with a given message.

Parameters:
message - one-line message describing successful outcome

failure

public static Outcome failure(String message)
Returns a failure outcome with a given message.

Parameters:
message - one-line message giving reason for failure

failure

public static Outcome failure(Throwable error)
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


Copyright © 2003-2018 CCLRC: Council for the Central Laboratory of the Research Councils. All Rights Reserved.