bdi4jade.core

## Class PlanLibrary

- java.lang.Object
- - bdi4jade.core.PlanLibrary

- All Implemented Interfaces:
    java.io.Serializable

      public class PlanLibrary
      extends java.lang.Object
      implements java.io.Serializable

  This class represents the plan library of a capability. It aggregates the plans that can be used to achieve goals.
  Author:
    ingrid
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PlanLibrary()` Creates a plan library.
    `PlanLibrary(java.util.Set<Plan> plans)` Creates a plan library base associated with a capability and adds the plans in the provided set.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addPlan(Plan plan)` Adds a plan to the plan library.
    `java.util.Set<Plan>` | `canAchievePlans(Goal goal)` Returns the set of plans that can achieve the given goal.
    `boolean` | `canProcessPlans(jade.lang.acl.ACLMessage message)` Returns true if there is a plan that can process the given message.
    `Capability` | `getCapability()`
    `java.util.Set<Plan>` | `getPlans()`
    `boolean` | `hasPlan(Plan plan)` Checks if a plan is part of the plan library.
    `boolean` | `removePlan(Plan plan)` Removes a plan from the plan library.
    `void` | `setCapability(Capability capability)` Sets the capability of this plan library.

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

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

- - ### Constructor Detail

    - #### PlanLibrary

          public PlanLibrary()

      Creates a plan library.

    - #### PlanLibrary

          public PlanLibrary(java.util.Set<Plan> plans)

      Creates a plan library base associated with a capability and adds the plans in the provided set.
      Parameters:
        `plans` - the initial plans

  - ### Method Detail

    - #### addPlan

          public void addPlan(Plan plan)

      Adds a plan to the plan library.
      Parameters:
        `plan` - the plan to be added.

    - #### canAchievePlans

          public java.util.Set<Plan> canAchievePlans(Goal goal)

      Returns the set of plans that can achieve the given goal.
      Parameters:
        `goal` - the goal to be achieved.
      Returns:
        the set of plans that can achieve the goal.

    - #### canProcessPlans

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

      Returns true if there is a plan that can process the given message.
      Parameters:
        `message` - the message to be processed.
      Returns:
        true if a plan can process the message.

    - #### getCapability

          public Capability getCapability()

      Returns:
        the capability

    - #### getPlans

          public java.util.Set<Plan> getPlans()

      Returns:
        the plans

    - #### hasPlan

          public boolean hasPlan(Plan plan)

      Checks if a plan is part of the plan library.
      Parameters:
        `plan` - the plan to be checked
      Returns:
        true if the plan library contains the plan.

    - #### removePlan

          public boolean removePlan(Plan plan)

      Removes a plan from the plan library.
      Parameters:
        `plan` - the plan to be removed.
      Returns:
        true if the plan was removed.

    - #### setCapability

          public void setCapability(Capability capability)

      Sets the capability of this plan library. If the capability was already set, it throws a `RuntimeException`. After setting the capability, the `init()` method is invoked.
      Parameters:
        `capability` - the capability to set