Enum Class FutureState

java.lang.Object
java.lang.Enum<FutureState>
com.tccc.kos.commons.util.concurrent.future.FutureState
All Implemented Interfaces:
Serializable, Comparable<FutureState>, Constable

public enum FutureState extends Enum<FutureState>
Possible FutureWork states, which are:
  • SUCCESS: the operation successfully ran to completion
  • FAIL: the operation ran to completion but failed
  • CANCEL: the operation was cancelled by the user
  • ABORT: the operation was aborted by the software
Since:
1.0
Version:
2023-01-23
  • Enum Constant Details

  • Method Details

    • values

      public static FutureState[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static FutureState valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • isSuccess

      public boolean isSuccess()
      Return true if the end state is SUCCESS . This indicates that the future ran to completion and was successful.
    • isFail

      public boolean isFail()
      Return true if the end state is FAIL . This indicates that the future ran to completion but failed to achieve the overall goal. For example, consider a future that turns on a motor. For safety reasons, the motor can only be run if the cover is closed. Sensing that the cover is open, the future would return FAIL to indicate that it didn't turn on the motor due to an expected precondition. FAIL and ABORT are conceptually similar but semantically FAIL represents an expected inability to complete the future successfully while ABORT is unexpected. This allows event handlers to process these conditions in different ways.
    • isCancel

      public boolean isCancel()
      Return true if the end state is CANCEL . This indicates that an external system requested that the future end before running to completion. Cancel can be considered a top-down event, typically coming from a user or higher level logic requesting that a process be ended early. For example, consider a future that runs a motor. For safety reasons, the motor can only run if the cover is closed. While the motor is running, a user opens the cover and the higher level software cancels the motor future to force the motor to stop.
    • isAbort

      public boolean isAbort()
      Return true if the end state is ABORT . This indicates that the future did not run to completion due to an internal error. This can be considered a bottom-up event, typically coming from the internal implementation of the future experiencing an unrecoverable error. For example, consider a future that runs a motor. A future turns the motor on but while running the temperature exceeds a safety limit. The future is aborted to stop the motor and indicate that it stopped for an unexpected reason. FAIL and ABORT are conceptually similar but semantically FAIL represents an expected inability to complete the future successfully while ABORT is unexpected. This allows event handlers to process these conditions in different ways.
    • isDone

      public boolean isDone()
      Return true if the end state is SUCCESS or FAIL . This indicates that the future ran to completion regardless of whether it was successful or failed.
    • isTerminate

      public boolean isTerminate()
      Return true if the end state is CANCEL or ABORT . This indicates that the future did not run to completion and ended earlier than expected.
    • isUnsuccess

      public boolean isUnsuccess()
      Return true if the end state is FAIL or ABORT . This indicates that the future was unsuccessful due to internal reasons. If a future is expected to be successful unless a user cancels it, then this indicates that the future was not successful.
    • getFutureEvent

      public FutureEvent getFutureEvent()
    • toString

      public String toString()
      Overrides:
      toString in class Enum<FutureState>