Class AbstractExitStatus

java.lang.Object
gov.nist.secauto.metaschema.cli.processor.AbstractExitStatus
All Implemented Interfaces:
ExitStatus
Direct Known Subclasses:
MessageExitStatus, NonMessageExitStatus

public abstract class AbstractExitStatus extends Object implements ExitStatus
Records information about the exit status of a CLI command.

This abstract class provides base functionality for handling CLI command exit statuses, including error logging and throwable management. Implementing classes must provide the getMessage() implementation to define the status message content.

  • Constructor Details

    • AbstractExitStatus

      public AbstractExitStatus(@NonNull ExitCode exitCode)
      Construct a new exit status based on the provided exitCode.
      Parameters:
      exitCode - the exit code
  • Method Details

    • getExitCode

      Description copied from interface: ExitStatus
      Get the exit code information associated with this exit status.
      Specified by:
      getExitCode in interface ExitStatus
      Returns:
      the exit code information
    • getThrowable

      Get the associated throwable.
      Specified by:
      getThrowable in interface ExitStatus
      Returns:
      the throwable or null
    • withThrowable

      public ExitStatus withThrowable(@NonNull Throwable throwable)
      Description copied from interface: ExitStatus
      Associate a throwable with the exit status.
      Specified by:
      withThrowable in interface ExitStatus
      Parameters:
      throwable - the throwable
      Returns:
      this exit status
    • getMessage

      @Nullable protected abstract String getMessage()
      Get the associated message.
      Returns:
      the message or null
    • generateMessage

      public void generateMessage(boolean showStackTrace)
      Generates and logs a message based on the current exit status. The message is logged at either INFO level (for success/info status) or ERROR level (for error status).
      Specified by:
      generateMessage in interface ExitStatus
      Parameters:
      showStackTrace - if true and a throwable is present, includes the stack trace in the log
      See Also: