bdi4jade.plan

## Class Plan

- java.lang.Object
- - bdi4jade.util.MetadataElement
  - - bdi4jade.plan.Plan

- Direct Known Subclasses:
    SimplePlan

      public abstract class Plan
      extends MetadataElement

  This class represents the plan abstraction. It defines the goals that the plan can achieve, in which context, and knows which is its plan body.
  Author:
    ingrid

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Plan.DefaultMetadata`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Plan(java.lang.String id)` Constructs a new Plan.
    `Plan(java.lang.String id, java.lang.Class<? extends Goal> goalClass)` Constructs a new Plan.
    `Plan(java.lang.String id, java.lang.Class<? extends Goal> goalClass, jade.lang.acl.MessageTemplate messageTemplate)` Constructs a new Plan.
    `Plan(java.lang.String id, jade.lang.acl.MessageTemplate messageTemplate)` Constructs a new Plan.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addGoal(java.lang.Class<? extends Goal> goalClass)` Adds a goal class that this plan may achieve.
    `void` | `addMessageTemplate(jade.lang.acl.MessageTemplate messageTemplate)` Adds a message template of messages that this plan can process.
    `boolean` | `canAchieve(Goal goal)` Verifies if a given goal can be achieved by this plan.
    `boolean` | `canProcess(jade.lang.acl.ACLMessage message)` Verifies if the message received matches with any of the message templates of this plan.
    `abstract jade.core.behaviours.Behaviour` | `createPlanBody()` Instantiate the plan body of this plan.
    `boolean` | `equals(java.lang.Object obj)`
    `java.lang.String` | `getId()`
    `PlanLibrary` | `getPlanLibrary()`
    `int` | `hashCode()`
    `void` | `setPlanLibrary(PlanLibrary planLibrary)`
    `java.lang.String` | `toString()`

    - ### Methods inherited from class bdi4jade.util.MetadataElement

      `getMetadata, getMetadata, hasMetadata, putMetadata, removeMetadata`

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

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Plan

          public Plan(java.lang.String id)

      Constructs a new Plan. It sets the plan library and plan body class of this plan, and initializes the goals that it can achieve and message templates of messages it can process.
      Parameters:
        `id` - plan identifier

    - #### Plan

          public Plan(java.lang.String id,
              java.lang.Class<? extends Goal> goalClass)

      Constructs a new Plan. It sets the plan library and plan body class of this plan, and initializes the goals that it can achieve and messages it can process. The goals are initialized with the provided goal class.
      Parameters:
        `id` - plan identifier
        `goalClass` - the goal that this plan can achieve

    - #### Plan

          public Plan(java.lang.String id,
              java.lang.Class<? extends Goal> goalClass,
              jade.lang.acl.MessageTemplate messageTemplate)

      Constructs a new Plan. It sets the plan library and plan body class of this plan, and initializes the goals that it can achieve and messages it can process. The goals are initialized with the provided goal class. The message templates is initialized with the provided template.
      Parameters:
        `id` - plan identifier
        `goalClass` - the goal that this plan can achieve
        `messageTemplate` - the template of messages that this plan can process.

    - #### Plan

          public Plan(java.lang.String id,
              jade.lang.acl.MessageTemplate messageTemplate)

      Constructs a new Plan. It sets the plan library and plan body class of this plan, and initializes the goals that it can achieve and message templates of messages it can process. The message templates is initialized with the provided template.
      Parameters:
        `id` - the plan identifier
        `messageTemplate` - the template of messages that this plan can process.

  - ### Method Detail

    - #### addGoal

          public void addGoal(java.lang.Class<? extends Goal> goalClass)

      Adds a goal class that this plan may achieve.
      Parameters:
        `goalClass` - the goal class that can be achieved by this plan.

    - #### addMessageTemplate

          public void addMessageTemplate(jade.lang.acl.MessageTemplate messageTemplate)

      Adds a message template of messages that this plan can process.
      Parameters:
        `messageTemplate` - the message template of messages that can be processed.

    - #### canAchieve

          public boolean canAchieve(Goal goal)

      Verifies if a given goal can be achieved by this plan. When the goal is a `MessageGoal`, it invokes the method `canProcess(ACLMessage)`. Otherwise, it checks if the class of this goal is contained in the goal set of this plan.
      Parameters:
        `goal` - the goal to be verified.
      Returns:
        true if the given goal can be achieved by this plan, false otherwise.

    - #### canProcess

          public boolean canProcess(jade.lang.acl.ACLMessage message)

      Verifies if the message received matches with any of the message templates of this plan.
      Parameters:
        `message` - the message to be checked.
      Returns:
        true if this plan can process the message.

    - #### createPlanBody

          public abstract jade.core.behaviours.Behaviour createPlanBody()
                                                                 throws PlanInstantiationException

      Instantiate the plan body of this plan. It must be an instance of `Behaviour` and also implements the `PlanBody` interface.
      Returns:
        the instantiated plan body.
      Throws:
        `PlanInstantiationException` - if an error occurred during the instantiation process.

    - #### equals

          public boolean equals(java.lang.Object obj)

      Overrides:
        `equals` in class `java.lang.Object`
      See Also:
        `Object.equals(java.lang.Object)`

    - #### getId

          public java.lang.String getId()

      Returns:
        the id

    - #### getPlanLibrary

          public PlanLibrary getPlanLibrary()

      Returns:
        the planLibrary

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`
      See Also:
        `Object.hashCode()`

    - #### setPlanLibrary

          public void setPlanLibrary(PlanLibrary planLibrary)

      Parameters:
        `planLibrary` - the planLibrary to set

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`
      See Also:
        `Object.toString()`