bdi4jade.core

## Class BeliefBase

- java.lang.Object
- - bdi4jade.core.BeliefBase

- All Implemented Interfaces:
    java.io.Serializable

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

  This class represents a belief base of a capability. It aggregates its knowledge.
  Author:
    ingrid
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BeliefBase()` Creates a belief base.
    `BeliefBase(java.util.Set<Belief<?>> beliefs)` Creates a belief base associated with a capability and adds the beliefs in the provided belief set.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addBelief(Belief<?> belief)` Adds a belief to the belief base.
    `void` | `addBeliefListener(BeliefListener beliefListener)` Adds a belief listener to be notified about changes in the belief base.
    `void` | `addOrUpdateBelief(Belief<?> belief)` Adds a belief to the belief base.
    `java.util.Collection<Belief<?>>` | `getAllBeliefs()` Gets all beliefs of this belief base and the belief bases of the parents of the capability that this belief base belongs to.
    `Belief<?>` | `getBelief(java.lang.String name)` Retrieves a belief from the belief base.
    `java.util.Set<BeliefListener>` | `getBeliefListeners()`
    `java.util.Set<Belief<?>>` | `getBeliefs()` Gets all beliefs of this belief base.
    `java.util.List<java.lang.Object>` | `getBeliefValues()` Return a list of all belief values from this belief base.
    `Capability` | `getCapability()`
    `boolean` | `hasBelief(java.lang.String name)` Checks if a belief is part of the belief base.
    `Belief<?>` | `removeBelief(java.lang.String name)` Removes a belief from the belief base.
    `void` | `removeBeliefListener(BeliefListener beliefListener)` Removes a belief listener.
    `void` | `reviewBeliefs()` This method is an empty place holder for subclasses.
    `void` | `setCapability(Capability capability)` Sets the capability of this belief base.
    `int` | `size()` Gets the size of this belief base (the number of beliefs).
    `java.lang.String` | `toString()`
    `boolean` | `updateBelief(java.lang.String name, java.lang.Object value)` Update the value of a belief in the belief base.

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

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

- - ### Constructor Detail

    - #### BeliefBase

          public BeliefBase()

      Creates a belief base.

    - #### BeliefBase

          public BeliefBase(java.util.Set<Belief<?>> beliefs)

      Creates a belief base associated with a capability and adds the beliefs in the provided belief set.
      Parameters:
        `beliefs` - the initial beliefs

  - ### Method Detail

    - #### addBelief

          public void addBelief(Belief<?> belief)

      Adds a belief to the belief base.
      Parameters:
        `belief` - the belief to be added.

    - #### addBeliefListener

          public void addBeliefListener(BeliefListener beliefListener)

      Adds a belief listener to be notified about changes in the belief base.
      Parameters:
        `beliefListener` - the listener to be added.

    - #### addOrUpdateBelief

          public void addOrUpdateBelief(Belief<?> belief)

      Adds a belief to the belief base. It overrides a belief, if it already exists.
      Parameters:
        `belief` - the belief to be added or updated.

    - #### getAllBeliefs

          public java.util.Collection<Belief<?>> getAllBeliefs()

      Gets all beliefs of this belief base and the belief bases of the parents of the capability that this belief base belongs to.
      Returns:
        the beliefs

    - #### getBelief

          public Belief<?> getBelief(java.lang.String name)

      Retrieves a belief from the belief base. If this belief does not contain it and this belief base is from a capability, it checks the common belief based of the agent, and returns it if it exists.
      Parameters:
        `name` - the name of the belief to be retrieved.
      Returns:
        the belief. Null if no belief is found.

    - #### getBeliefListeners

          public java.util.Set<BeliefListener> getBeliefListeners()

      Returns:
        the beliefListeners

    - #### getBeliefs

          public java.util.Set<Belief<?>> getBeliefs()

      Gets all beliefs of this belief base.
      Returns:
        the beliefs

    - #### getBeliefValues

          public java.util.List<java.lang.Object> getBeliefValues()

      Return a list of all belief values from this belief base.
      Returns:
        the beliefValues

    - #### getCapability

          public Capability getCapability()

      Returns:
        the capability

    - #### hasBelief

          public boolean hasBelief(java.lang.String name)

      Checks if a belief is part of the belief base.
      Parameters:
        `name` - the belief to be checked
      Returns:
        true if the belief base contains the belief.

    - #### removeBelief

          public Belief<?> removeBelief(java.lang.String name)

      Removes a belief from the belief base.
      Parameters:
        `name` - the name of the belief to be removed.
      Returns:
        the belief was removed, null if it is not part of the belief base.

    - #### removeBeliefListener

          public void removeBeliefListener(BeliefListener beliefListener)

      Removes a belief listener.
      Parameters:
        `beliefListener` - the listener to be removed.

    - #### reviewBeliefs

          public void reviewBeliefs()

      This method is an empty place holder for subclasses. It may be invoked to review beliefs from this belief base.

    - #### setCapability

          public void setCapability(Capability capability)

      Sets the capability of this belief base. 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

    - #### size

          public int size()

      Gets the size of this belief base (the number of beliefs).
      Returns:
        the size of this belief base.

    - #### toString

          public java.lang.String toString()

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

    - #### updateBelief

          public boolean updateBelief(java.lang.String name,
                             java.lang.Object value)

      Update the value of a belief in the belief base. In case the belief is not present in the belief base, nothing is performed and the method returns false. If the type of the new value being provided, it is still going to subscribe the previous value.
      Parameters:
        `name` - the belief to be updated.
        `value` - the new value to the belief.
      Returns:
        true if the belief was update.