bdi4jade.plan.planbody

## Class BeliefGoalPlanBody

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

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

      public abstract class BeliefGoalPlanBody
      extends AbstractPlanBody

  This plan body aims to achieve a `BeliefGoal`. It verifies when the plan begins its execution if the goal is already achieved. If so, nothing is performed, otherwise the method `execute()` is invoked, as a replacement of the `action()` method.
  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 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
    `BeliefGoalPlanBody()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `action()` This final implementation of the action method verifies the belief goal that triggered this plan body execution is already achieved ( `isGoalAchieved()`).
    `protected abstract void` | `execute()` This method is a placeholder for subclasses that should implement the set of steps needed to achieve this plan body goal.
    `protected void` | `init()` This method is a placeholder for subclasses.
    `protected boolean` | `isGoalAchieved()` Returns true if the goal of this plan body was achieved.
    `void` | `onStart()` Verifies if the goal that triggered this plan body execution is a `BeliefGoal`.

    - ### 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`

- - ### Constructor Detail

    - #### BeliefGoalPlanBody

          public BeliefGoalPlanBody()

  - ### Method Detail

    - #### action

          public final void action()

      This final implementation of the action method verifies the belief goal that triggered this plan body execution is already achieved ( `isGoalAchieved()`). If not, it invokes the `execute()` method;
      Specified by:
        `action` in class `jade.core.behaviours.Behaviour`

    - #### execute

          protected abstract void execute()

      This method is a placeholder for subclasses that should implement the set of steps needed to achieve this plan body goal.

    - #### init

          protected void init()

      This method is a placeholder for subclasses. It is invoked by the `onStart()` method, after it performs some pre-processing.

    - #### isGoalAchieved

          protected boolean isGoalAchieved()

      Returns true if the goal of this plan body was achieved. If so, it sets the end state to successful, which cases this plan body to complete its execution.
      Returns:
        true if goal was achieved, false otherwise.

    - #### onStart

          public final void onStart()

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