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.booleanisFail()When the action is marked as failed(ActionState.COMPLETE_WITH_ERROR), then it's called fail.protected voidPerform single-phased browser action.toString()Methods inherited from class org.kquiet.browser.action.SinglePhaseAction
performMultiPhaseMethods inherited from class org.kquiet.browser.action.MultiPhaseAction
getActionState, getComposer, getCostTime, hasNextPhase, isDone, noNextPhase, perform, setActionState, setComposer, switchToTopForFirefoxMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:SinglePhaseActionPerform single-phased browser action.- Specified by:
performSinglePhasein classSinglePhaseAction
-
toString
- Overrides:
toStringin classMultiPhaseAction
-
isFail
public boolean isFail()Description copied from class:MultiPhaseActionWhen the action is marked as failed(ActionState.COMPLETE_WITH_ERROR), then it's called fail.- Specified by:
isFailin interfaceComposable- Overrides:
isFailin classMultiPhaseAction- Returns:
trueif the action is failed;falseotherwise
-
getErrors
Description copied from interface:ComposableGet the errors occurred during execution.- Specified by:
getErrorsin interfaceComposable- Overrides:
getErrorsin 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:
addToHeadin 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:
addToTailin 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:
addToPositionin interfaceDynamicActionSequence- Parameters:
action- action to addposition- the position(zero-based) to add given action- Returns:
- self reference
-