Package org.kquiet.browser.action
Class IfThenElse
java.lang.Object
org.kquiet.browser.action.MultiPhaseAction
org.kquiet.browser.action.SinglePhaseAction
org.kquiet.browser.action.IfThenElse
- All Implemented Interfaces:
Composable
,MultiPhased
,DynamicActionSequence
IfThenElse
is a subclass of SinglePhaseAction
which performs actions according to
the evaluation result of specified function. If this function returns something different from
null or false then the result is positive; otherwise negative.
IfThenElse
maintains two lists of actions internally:
- positive action list - list of actions to perform for positive result
- negative action list - list of actions to perform for negative result
- Author:
- Kimberly
-
Constructor Summary
ConstructorsConstructorDescriptionIfThenElse
(Function<ActionComposer, ?> evalFunction, List<Composable> positiveActionList, List<Composable> negativeActionList) Create an action representing if-then-else condition. -
Method Summary
Modifier and TypeMethodDescriptionaddToHead
(Composable action) Add action to the head of positive or negative list.addToPosition
(Composable action, int position) Add action to the the specified position of positive or negative list.addToTail
(Composable action) Add action to the tail of positive or negative list.Get the errors occurred during execution.boolean
isFail()
When the action is marked as failed(ActionState.COMPLETE_WITH_ERROR
), then it's called fail.protected void
Perform single-phased browser action.toString()
Methods inherited from class org.kquiet.browser.action.SinglePhaseAction
performMultiPhase
Methods inherited from class org.kquiet.browser.action.MultiPhaseAction
getActionState, getComposer, getCostTime, hasNextPhase, isDone, noNextPhase, perform, setActionState, setComposer, switchToTopForFirefox
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.kquiet.browser.DynamicActionSequence
add
-
Constructor Details
-
IfThenElse
public IfThenElse(Function<ActionComposer, ?> evalFunction, List<Composable> positiveActionList, List<Composable> negativeActionList) Create an action representing if-then-else condition.- Parameters:
evalFunction
- the function to evaluatepositiveActionList
- the actions to perform if the result is truenegativeActionList
- the actions to perform if the result is false
-
-
Method Details
-
performSinglePhase
protected void performSinglePhase()Description copied from class:SinglePhaseAction
Perform single-phased browser action.- Specified by:
performSinglePhase
in classSinglePhaseAction
-
toString
- Overrides:
toString
in classMultiPhaseAction
-
isFail
public boolean isFail()Description copied from class:MultiPhaseAction
When the action is marked as failed(ActionState.COMPLETE_WITH_ERROR
), then it's called fail.- Specified by:
isFail
in interfaceComposable
- Overrides:
isFail
in classMultiPhaseAction
- Returns:
true
if the action is failed;false
otherwise
-
getErrors
Description copied from interface:Composable
Get the errors occurred during execution.- Specified by:
getErrors
in interfaceComposable
- Overrides:
getErrors
in classMultiPhaseAction
- Returns:
- the errors as a list of
Exception
-
addToHead
Add action to the head of positive or negative list. It depends on the evaluation result and does nothing before evaulation.- Specified by:
addToHead
in interfaceDynamicActionSequence
- Parameters:
action
- action to add- Returns:
- self reference
-
addToTail
Add action to the tail of positive or negative list. It depends on the evaluation result and does nothing before evaulation.- Specified by:
addToTail
in interfaceDynamicActionSequence
- Parameters:
action
- action to add- Returns:
- self reference
-
addToPosition
Add action to the the specified position of positive or negative list. It depends on the evaluation result and does nothing before evaulation.- Specified by:
addToPosition
in interfaceDynamicActionSequence
- Parameters:
action
- action to addposition
- the position(zero-based) to add given action- Returns:
- self reference
-