Class ForLoop<InputType>
- Type Parameters:
InputType
-
- All Implemented Interfaces:
AttachableCommand<InputType>
,BypassableCommand<InputType>
,Command<InputType>
,OrchestrationAware<InputType>
This command has the four components of a typical 'for' loop:
This command runs in two modes that are determined by the value of "evaluateAfterEveryCommand"
If evaluateAfterEveryCommand is true then the condition is evaluated after every command. If it is condition is true then the command aborts after the command.Else it continues.
If evaluateAfterEveryCommand is false then the condition is evaluated once after all the commands. If the condition is true then it repeats.
Please see the test case for a good example of this.
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final String
private static final String
private static final String
private CommandDescriptor<InputType>
Fields inherited from class org.chenile.owiz.impl.Chain
commandDescSet, currentIndex, INDEX
Fields inherited from class org.chenile.owiz.impl.CommandBase
commandDescriptor, orchConfigurator
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
attachCommand
(AttachmentDescriptor<InputType> attachmentDescriptor, CommandDescriptor<InputType> command) Allow a command to attach itself to this chain.protected void
protected boolean
isConditionTrue
(InputType context) protected boolean
shouldRepeat
(InputType context) Determines if the loop should repeat.protected boolean
shouldStopChain
(InputType context) AN extension point to allow sub classes to stop a chain if a condition is satisfied.Methods inherited from class org.chenile.owiz.impl.Chain
obtainExecutionCommands
Methods inherited from class org.chenile.owiz.impl.CommandBase
bypass, execute, getConfigValue, getId, getParentId, obtainCommand, postprocess, preprocess, setCommandDescriptor, setOrchConfigurator
-
Field Details
-
CONDITION
- See Also:
-
INCREMENT
- See Also:
-
EVALUATE_AFTER_EVERY_COMMAND
- See Also:
-
incrementCommand
-
-
Constructor Details
-
ForLoop
public ForLoop()
-
-
Method Details
-
shouldRepeat
Determines if the loop should repeat. If the condition expression does not exist, it will evaluate to false.The increment command (if it exists) is then executed before evaluating the condition using OGNL
Note that if the incrementCommand does not exist, then the body of the loop must have done the incrementation (just like a normal for loop). Else there can be an infinite loop!
- Parameters:
context
- the execution context- Returns:
- true if loops should repeat, false otherwise.
- Throws:
Exception
- OGNL exception
-
isConditionTrue
- Throws:
Exception
-
shouldStopChain
Description copied from class:Chain
AN extension point to allow sub classes to stop a chain if a condition is satisfied.- Overrides:
shouldStopChain
in classChain<InputType>
- Parameters:
context
- containing the data required.- Returns:
- false by default.
- Throws:
Exception
- .
-
doExecute
-
attachCommand
public void attachCommand(AttachmentDescriptor<InputType> attachmentDescriptor, CommandDescriptor<InputType> command) Description copied from class:Chain
Allow a command to attach itself to this chain. If the index is not specified then the attachment order defines the execution order. Else if index is explicitly specified then the execution order would be the ascending order of the index.- Specified by:
attachCommand
in interfaceAttachableCommand<InputType>
- Overrides:
attachCommand
in classChain<InputType>
-