Class JumpInstruction
java.lang.Object
dev.zemco.codegame.execution.instructions.JumpInstruction
- All Implemented Interfaces:
IInstruction
- Direct Known Subclasses:
JumpIfZeroInstruction
Instruction that performs a jump of the
engine to the specified label.- Author:
- Erik Zemčík
-
Constructor Summary
ConstructorsConstructorDescriptionJumpInstruction(String label) Creates an instance ofJumpInstructionwith the target jump label. -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute(IExecutionContext executionContext) Requests theengineto perform a jump to the target jump label.protected booleanshouldPerformJump(IExecutionContext executionContext) Checks if the instruction should request theengineto perform a jump.
-
Constructor Details
-
JumpInstruction
Creates an instance ofJumpInstructionwith the target jump label.- Parameters:
label- target label of the jump- Throws:
IllegalArgumentException- iflabelisnullor empty
-
-
Method Details
-
execute
Requests theengineto perform a jump to the target jump label.- Specified by:
executein interfaceIInstruction- Parameters:
executionContext- context on which the instruction is executed- Throws:
IllegalArgumentException- ifexecutionContextisnullInstructionExecutionException- if the target label is not known by theengine
-
shouldPerformJump
protected boolean shouldPerformJump(IExecutionContext executionContext) throws InstructionExecutionException Checks if the instruction should request theengineto perform a jump. This method is intended to be overridden by subclasses requiring more advanced jumping logic.- Parameters:
executionContext- context on which the instruction is executed- Returns:
- true if the jump should be performed, else false
- Throws:
InstructionExecutionException- if illegal state during the check is reached
-