Class CommandInterpretResult

java.lang.Object
org.kigalisim.command.CommandInterpretResult

public class CommandInterpretResult extends Object
Result of interpreting QubecTalk code.

Contains either a successfully parsed program, an error message, or neither (for validation success without returning a program). At most one of program or error message will be present.

  • Constructor Details

    • CommandInterpretResult

      public CommandInterpretResult()
      Creates a successful interpretation result without a program.

      Used when validation succeeds but the program is not needed.

    • CommandInterpretResult

      public CommandInterpretResult(ParsedProgram program)
      Creates a successful interpretation result.
      Parameters:
      program - The successfully parsed program
    • CommandInterpretResult

      public CommandInterpretResult(String errorMessage)
      Creates a failed interpretation result.
      Parameters:
      errorMessage - The error message
  • Method Details

    • getProgram

      public Optional<ParsedProgram> getProgram()
      Returns the parsed program if interpretation succeeded.
      Returns:
      An Optional containing the successfully parsed program, or empty if interpretation failed
    • getErrorMessage

      public Optional<String> getErrorMessage()
      Returns the error message if interpretation failed.
      Returns:
      An Optional containing the error message, or empty if interpretation succeeded
    • getIsSuccess

      public boolean getIsSuccess()
      Checks if the interpretation was successful.
      Returns:
      true if a program is present, false otherwise
    • getIsFailure

      public boolean getIsFailure()
      Checks if the interpretation failed.
      Returns:
      true if an error message is present, false otherwise