Package org.kigalisim.command
Class CommandInterpretResult
java.lang.Object
org.kigalisim.command.CommandInterpretResult
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 Summary
ConstructorsConstructorDescriptionCreates a successful interpretation result without a program.CommandInterpretResult(String errorMessage) Creates a failed interpretation result.CommandInterpretResult(ParsedProgram program) Creates a successful interpretation result. -
Method Summary
Modifier and TypeMethodDescriptionReturns the error message if interpretation failed.booleanChecks if the interpretation failed.booleanChecks if the interpretation was successful.Returns the parsed program if interpretation succeeded.
-
Constructor Details
-
CommandInterpretResult
public CommandInterpretResult()Creates a successful interpretation result without a program.Used when validation succeeds but the program is not needed.
-
CommandInterpretResult
Creates a successful interpretation result.- Parameters:
program- The successfully parsed program
-
CommandInterpretResult
Creates a failed interpretation result.- Parameters:
errorMessage- The error message
-
-
Method Details
-
getProgram
Returns the parsed program if interpretation succeeded.- Returns:
- An Optional containing the successfully parsed program, or empty if interpretation failed
-
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
-