public abstract class ParamsAction<CONTEXT extends Context> extends StateAction<CONTEXT>
actions that have parameters passed to them
using the reflection API. The actions derived directly from StateAction
must check that passed VariableContext contains expected parameters.
To correctly implement action that can utilize the reflection for parameters,
you must derive from this class and implement three methods: public void
init, public ActionResult run and public void done.
All parameters of these methods must be annotated by the Param with
specified name of the variable contained in the VariableContext. Note
that each action can have different parameters, as long as all parameters
have annotations with Param and are all in the context.
Only allowed parameters are of type String, Integer and Double.
Example:
class StayAction extends ParamsAction<PreyContext> {
public StayAction(Context ctx) {
super(ctx);
}
public void init(&064;Param("$enemy") String enemy, &064;Param("$distance") Double distance) {
...
}
public ActionResult run(&064;Param("$teamname") String teamName) {
...
}
public void done() {
...
}
}
ParamsSense,
Annotation for parameters of the methods.ctx| Constructor and Description |
|---|
ParamsAction(CONTEXT ctx) |
| Modifier and Type | Method and Description |
|---|---|
void |
done(VariableContext params)
This action is done, according to posh plan, some other
IAction is
supposed to execute, therefore use this to clean up the mess. |
void |
init(VariableContext params)
Initialize action.
|
ActionResult |
run(VariableContext params)
Run is called every time evaluation of posh plan determines that this and
no other action is the one that is supposed to execute.
|
getCtx, getNamepublic ParamsAction(CONTEXT ctx)
public final void init(VariableContext params)
IActionparams - Variable context that is passed from posh plan to the primitivepublic final ActionResult run(VariableContext params)
IActionparams - Variable context passed from posh plan to the primtivepublic final void done(VariableContext params)
IActionIAction is
supposed to execute, therefore use this to clean up the mess.Copyright © 2018 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All rights reserved.