bdi4jade.goal

## Class CompositeGoal

- java.lang.Object
- - bdi4jade.goal.CompositeGoal

- All Implemented Interfaces:
    Goal, jade.content.Concept, jade.content.ContentElement, jade.content.Term, java.io.Serializable
  Direct Known Subclasses:
    ParallelGoal, SequentialGoal

      public abstract class CompositeGoal
      extends java.lang.Object
      implements Goal

  This class represents a goal that is a composition of other goals (subgoals). It has two main subclasses, which indicate if the goals must be achieved in a parallel or sequential way.
  Author:
    Ingrid Nunes
  See Also:
    Serialized Form

- - ### Field Summary

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

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CompositeGoal(java.util.Collection<Goal> goals)` Instantiates a CompositeGoal with the provided goals.
    `CompositeGoal(Goal[] goals)` Instantiates a CompositeGoal with the provided goals array.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract java.util.Collection<Goal>` | `createGoals(int size)` Creates an instance of the collection that holds the goals of this composite goal.
    `java.util.List<Goal>` | `getCompletedGoals()` Returns the goals of this composite goal that successfully finished.
    `GoalEvent` | `getFailedGoal()` Returns the goal event associated with a goal that could not be achieved, if any.
    `java.util.Collection<Goal>` | `getGoals()` Returns the goals associated with this composite goal.
    `void` | `setCompletedGoals(java.util.List<Goal> completedGoals)` Sets the list of completed goals.
    `void` | `setFailedGoal(GoalEvent failedGoal)` Sets the goal event associated with the goal that failed.

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

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

- - ### Field Detail

    - #### completedGoals

          protected java.util.List<Goal> completedGoals

    - #### failedGoal

          protected GoalEvent failedGoal

    - #### goals

          protected final java.util.Collection<Goal> goals

  - ### Constructor Detail

    - #### CompositeGoal

          public CompositeGoal(java.util.Collection<Goal> goals)

      Instantiates a CompositeGoal with the provided goals.
      Parameters:
        `goals` - the goals that compose this goal.

    - #### CompositeGoal

          public CompositeGoal(Goal[] goals)

      Instantiates a CompositeGoal with the provided goals array. A `Collection` is instantiated by the method `createGoals(int)` and is initialized with the provided goals.
      Parameters:
        `goals` - the goals that compose this goal.

  - ### Method Detail

    - #### createGoals

          protected abstract java.util.Collection<Goal> createGoals(int size)

      Creates an instance of the collection that holds the goals of this composite goal.
      Parameters:
        `size` - the size of the collection.
      Returns:
        the collection.

    - #### getCompletedGoals

          public java.util.List<Goal> getCompletedGoals()

      Returns the goals of this composite goal that successfully finished.
      Returns:
        the completedGoals the goals that were achieved.

    - #### getFailedGoal

          public GoalEvent getFailedGoal()

      Returns the goal event associated with a goal that could not be achieved, if any. If it is not possible to achieve one of the goals, the remaining goals that were not completed yet will not be achieved. If there are goals part of this composite goal that are being tried to be achieved, they become no longer desired.
      Returns:
        the goal that failed.

    - #### getGoals

          public java.util.Collection<Goal> getGoals()

      Returns the goals associated with this composite goal.
      Returns:
        the goals.

    - #### setCompletedGoals

          public void setCompletedGoals(java.util.List<Goal> completedGoals)

      Sets the list of completed goals.
      Parameters:
        `completedGoals` - the completedGoals to set.

    - #### setFailedGoal

          public void setFailedGoal(GoalEvent failedGoal)

      Sets the goal event associated with the goal that failed.
      Parameters:
        `failedGoal` - the failedGoal to set.