org.springframework.batch.core

## Class ExitStatus

- java.lang.Object
- - org.springframework.batch.core.ExitStatus

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<ExitStatus>

      public class ExitStatus
      extends java.lang.Object
      implements java.io.Serializable, java.lang.Comparable<ExitStatus>

  Value object used to carry information about the status of a job or step execution. ExitStatus is immutable and therefore thread-safe.
  Author:
    Dave Syer
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static ExitStatus` | `COMPLETED` Convenient constant value representing finished processing.
    `static ExitStatus` | `EXECUTING` Convenient constant value representing continuable state where processing is still taking place, so no further action is required.
    `static ExitStatus` | `FAILED` Convenient constant value representing finished processing with an error.
    `static ExitStatus` | `NOOP` Convenient constant value representing job that did no processing (e.g.
    `static ExitStatus` | `STOPPED` Convenient constant value representing finished processing with interrupted status.
    `static ExitStatus` | `UNKNOWN` Convenient constant value representing unknown state - assumed not continuable.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ExitStatus(java.lang.String exitCode)`
    `ExitStatus(java.lang.String exitCode, java.lang.String exitDescription)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ExitStatus` | `addExitDescription(java.lang.String description)` Add an exit description to an existing `ExitStatus`.
    `ExitStatus` | `addExitDescription(java.lang.Throwable throwable)` Extract the stack trace from the throwable provided and append it to the exist description.
    `ExitStatus` | `and(ExitStatus status)` Create a new `ExitStatus` with a logical combination of the exit code, and a concatenation of the descriptions.
    `int` | `compareTo(ExitStatus status)`
    `boolean` | `equals(java.lang.Object obj)` Compare the fields one by one.
    `java.lang.String` | `getExitCode()` Getter for the exit code (defaults to blank).
    `java.lang.String` | `getExitDescription()` Getter for the exit description (defaults to blank)
    `int` | `hashCode()` Compatible with the equals implementation.
    `static boolean` | `isNonDefaultExitStatus(ExitStatus status)`
    `boolean` | `isRunning()` Check if this status represents a running process.
    `ExitStatus` | `replaceExitCode(java.lang.String code)` Add an exit code to an existing `ExitStatus`.
    `java.lang.String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### UNKNOWN

          public static final ExitStatus UNKNOWN

      Convenient constant value representing unknown state - assumed not continuable.

    - #### EXECUTING

          public static final ExitStatus EXECUTING

      Convenient constant value representing continuable state where processing is still taking place, so no further action is required. Used for asynchronous execution scenarios where the processing is happening in another thread or process and the caller is not required to wait for the result.

    - #### COMPLETED

          public static final ExitStatus COMPLETED

      Convenient constant value representing finished processing.

    - #### NOOP

          public static final ExitStatus NOOP

      Convenient constant value representing job that did no processing (e.g. because it was already complete).

    - #### FAILED

          public static final ExitStatus FAILED

      Convenient constant value representing finished processing with an error.

    - #### STOPPED

          public static final ExitStatus STOPPED

      Convenient constant value representing finished processing with interrupted status.

  - ### Constructor Detail

    - #### ExitStatus

          public ExitStatus(java.lang.String exitCode)

    - #### ExitStatus

          public ExitStatus(java.lang.String exitCode,
                            java.lang.String exitDescription)

  - ### Method Detail

    - #### getExitCode

          public java.lang.String getExitCode()

      Getter for the exit code (defaults to blank).
      Returns:
        the exit code.

    - #### getExitDescription

          public java.lang.String getExitDescription()

      Getter for the exit description (defaults to blank)
      Returns:
        `String` containing the exit description.

    - #### and

          public ExitStatus and(ExitStatus status)

      Create a new `ExitStatus` with a logical combination of the exit code, and a concatenation of the descriptions. If either value has a higher severity then its exit code will be used in the result. In the case of equal severity, the exit code is replaced if the new value is alphabetically greater.
      Severity is defined by the exit code:
      - Codes beginning with EXECUTING have severity 1
      - Codes beginning with COMPLETED have severity 2
      - Codes beginning with NOOP have severity 3
      - Codes beginning with STOPPED have severity 4
      - Codes beginning with FAILED have severity 5
      - Codes beginning with UNKNOWN have severity 6
      Others have severity 7, so custom exit codes always win.
      If the input is null just return this.
      Parameters:
        `status` - an `ExitStatus` to combine with this one.
      Returns:
        a new `ExitStatus` combining the current value and the argument provided.

    - #### compareTo

          public int compareTo(ExitStatus status)

      Specified by:
        `compareTo` in interface `java.lang.Comparable<ExitStatus>`
      Parameters:
        `status` - an `ExitStatus` to compare
      Returns:
        greater than zero, 0, less than zero according to the severity and exit code
      See Also:
        `Comparable`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### equals

          public boolean equals(java.lang.Object obj)

      Compare the fields one by one.
      Overrides:
        `equals` in class `java.lang.Object`
      See Also:
        `Object.equals(java.lang.Object)`

    - #### hashCode

          public int hashCode()

      Compatible with the equals implementation.
      Overrides:
        `hashCode` in class `java.lang.Object`
      See Also:
        `Object.hashCode()`

    - #### replaceExitCode

          public ExitStatus replaceExitCode(java.lang.String code)

      Add an exit code to an existing `ExitStatus`. If there is already a code present tit will be replaced.
      Parameters:
        `code` - the code to add
      Returns:
        a new `ExitStatus` with the same properties but a new exit code.

    - #### isRunning

          public boolean isRunning()

      Check if this status represents a running process.
      Returns:
        true if the exit code is "EXECUTING" or "UNKNOWN"

    - #### addExitDescription

          public ExitStatus addExitDescription(java.lang.String description)

      Add an exit description to an existing `ExitStatus`. If there is already a description present the two will be concatenated with a semicolon.
      Parameters:
        `description` - the description to add
      Returns:
        a new `ExitStatus` with the same properties but a new exit description

    - #### addExitDescription

          public ExitStatus addExitDescription(java.lang.Throwable throwable)

      Extract the stack trace from the throwable provided and append it to the exist description.
      Parameters:
        `throwable` - `Throwable` instance containing the stack trace.
      Returns:
        a new ExitStatus with the stack trace appended

    - #### isNonDefaultExitStatus

          public static boolean isNonDefaultExitStatus(ExitStatus status)

      Parameters:
        `status` - the exit code to be evaluated
      Returns:
        true if the value matches a known exit code