bdi4jade.plan.planbody

## Class SequentialGoalPlanBody

- java.lang.Object
- - jade.core.behaviours.Behaviour
  - - bdi4jade.plan.planbody.AbstractPlanBody
    - - bdi4jade.plan.planbody.SequentialGoalPlanBody

- All Implemented Interfaces:
    GoalListener, OutputPlanBody, PlanBody, java.io.Serializable, java.util.EventListener

      public class SequentialGoalPlanBody
      extends AbstractPlanBody
      implements OutputPlanBody

  This plan body provides the set of actions to achieve a `SequentialGoal`.
  Author:
    Ingrid Nunes
  See Also:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class jade.core.behaviours.Behaviour

      `jade.core.behaviours.Behaviour.RunnableChangedEvent`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.List<Goal>` | `completedGoals`
    `protected Goal` | `currentGoal`
    `protected GoalEvent` | `failedGoal`
    `protected java.util.Iterator<Goal>` | `it`

    - ### Fields inherited from class jade.core.behaviours.Behaviour

      `myAgent, myEvent, NOTIFY_DOWN, NOTIFY_UP, parent, STATE_BLOCKED, STATE_READY, STATE_RUNNING`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SequentialGoalPlanBody()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `action()` This method tries to achieve all subgoals of the `SequentialGoal` to be achieved sequentially.
    `void` | `onStart()` Initializes this plan.
    `void` | `setGoalOutput(Goal goal)` Sets completed goals, and the failed goal, if there is one.
    `protected void` | `setNextGoal(Goal previousGoal, Goal goal)` Sets the parameters of the next goal to be executed based on the previous goal execution.

    - ### Methods inherited from class bdi4jade.plan.planbody.AbstractPlanBody

      `dispatchGoal, dispatchSubgoal, dispatchSubgoalAndListen, done, getBeliefBase, getCapability, getEndState, getGoal, getGoalEvent, getGoalEvent, getGoalEvent, getPlan, goalPerformed, init, setEndState, start, stop`

    - ### Methods inherited from class jade.core.behaviours.Behaviour

      `actionWrapper, block, block, getAgent, getBehaviourName, getDataStore, getExecutionState, getParent, getRestartCounter, handle, handleBlockEvent, handleRestartEvent, isRunnable, onEnd, reset, restart, root, setAgent, setBehaviourName, setDataStore, setExecutionState`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface bdi4jade.plan.planbody.PlanBody

      `onEnd, reset`

- - ### Field Detail

    - #### completedGoals

          protected java.util.List<Goal> completedGoals

    - #### currentGoal

          protected Goal currentGoal

    - #### failedGoal

          protected GoalEvent failedGoal

    - #### it

          protected java.util.Iterator<Goal> it

  - ### Constructor Detail

    - #### SequentialGoalPlanBody

          public SequentialGoalPlanBody()

  - ### Method Detail

    - #### action

          public void action()

      This method tries to achieve all subgoals of the `SequentialGoal` to be achieved sequentially. If one of the subgoals fail, it stops the plan body execution.
      Specified by:
        `action` in class `jade.core.behaviours.Behaviour`
      See Also:
        `Behaviour.action()`

    - #### onStart

          public void onStart()

      Initializes this plan. Starts the goals iterator and verifies if the goal that triggered this plan body execution is a `SequentialGoal`. If not, it throws an `IllegalArgumentException`.
      Specified by:
        `onStart` in interface `PlanBody`
      Overrides:
        `onStart` in class `jade.core.behaviours.Behaviour`
      See Also:
        `Behaviour.onStart()`

    - #### setGoalOutput

          public void setGoalOutput(Goal goal)

      Sets completed goals, and the failed goal, if there is one.
      Specified by:
        `setGoalOutput` in interface `OutputPlanBody`
      Parameters:
        `goal` - the goal whose output parameters are to be set.
      See Also:
        `OutputPlanBody.setGoalOutput(bdi4jade.goal.Goal)`

    - #### setNextGoal

          protected void setNextGoal(Goal previousGoal,
                                     Goal goal)
                              throws ParameterException

      Sets the parameters of the next goal to be executed based on the previous goal execution. It should be overridden by subclass of goals are not annotated with the `Parameter` annotation.
      Parameters:
        `previousGoal` - the previously executed goal.
        `goal` - the goal that is going to be dispatched.
      Throws:
        `ParameterException` - if an error occurred during setting up the next goal.