bdi4jade.belief

## Class DerivedBelief<K,V>

- java.lang.Object
- - bdi4jade.core.MetadataElementImpl
  - - bdi4jade.belief.AbstractBelief<K,V>
    - - bdi4jade.belief.DerivedBelief<K,V>

- All Implemented Interfaces:
    Belief<K,V>, MetadataElement, jade.content.Concept, jade.content.ContentElement, jade.content.Term, java.io.Serializable, java.lang.Cloneable
  Direct Known Subclasses:
    DerivedPredicate

      public abstract class DerivedBelief<K,V>
      extends AbstractBelief<K,V>

  This class represents a belief whose value is derived from other beliefs of a belief base. As a belief may be part of many belief bases, a main belief base is associated with this belief. The evaluation of the value of this belief is performed considering the belief of the main belief base.
  Author:
    Ingrid Nunes
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class bdi4jade.core.MetadataElementImpl

      `metadata`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DerivedBelief()` The default constructor.
    `DerivedBelief(K name)` Creates a new derived belief.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addBeliefBase(BeliefBase beliefBase)` Adds a belief base with which this belief is associated.
    `protected abstract V` | `evaluate()` Evaluates the value of this belief, which is derived from beliefs of the main belief base associated with this belief.
    `BeliefBase` | `getMainBeliefBase()` Returns the main belief base of this belief.
    `V` | `getValue()` Returns the value of this belief.
    `void` | `removeBeliefBase(BeliefBase beliefBase)` Removes a belief base associated with this belief.
    `void` | `setMainBeliefBase(BeliefBase mainBeliefBase)` Sets the main belief base of this belief.
    `protected void` | `updateValue(V value)` This method throws a `NullPointerException`, as this operation is invalid for this belief.

    - ### Methods inherited from class bdi4jade.belief.AbstractBelief

      `clone, equals, getBeliefBases, getName, hashCode, notifyBeliefBases, setName, setValue, toString`

    - ### Methods inherited from class bdi4jade.core.MetadataElementImpl

      `getMetadata, getMetadata, hasMetadata, putMetadata, removeMetadata`

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

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

    - ### Methods inherited from interface bdi4jade.core.MetadataElement

      `getMetadata, getMetadata, hasMetadata, putMetadata, removeMetadata`

- - ### Constructor Detail

    - #### DerivedBelief

          public DerivedBelief()

      The default constructor. It should be only used if persistence frameworks are used.

    - #### DerivedBelief

          public DerivedBelief(K name)

      Creates a new derived belief. The value of this belief cannot be set as it is derived from other values of a belief base.
      Parameters:
        `name` - the belief name.

  - ### Method Detail

    - #### addBeliefBase

          public void addBeliefBase(BeliefBase beliefBase)

      Adds a belief base with which this belief is associated. If the main belief base of this belief is null, it sets the given belief base as the main belief base of this belief.
      Specified by:
        `addBeliefBase` in interface `Belief<K,V>`
      Overrides:
        `addBeliefBase` in class `AbstractBelief<K,V>`
      Parameters:
        `beliefBase` - the belief base to be added.
      See Also:
        `AbstractBelief.addBeliefBase(bdi4jade.belief.BeliefBase)`

    - #### evaluate

          protected abstract V evaluate()

      Evaluates the value of this belief, which is derived from beliefs of the main belief base associated with this belief.
      Returns:
        the value of this belief.

    - #### getMainBeliefBase

          public BeliefBase getMainBeliefBase()

      Returns the main belief base of this belief.
      Returns:
        the main belief base.

    - #### getValue

          public V getValue()

      Returns the value of this belief. If the main belief base is null, it returns null. Otherwise, the method `evaluate()` is invoked.
      Returns:
        the value of this belief.
      See Also:
        `Belief.getValue()`

    - #### removeBeliefBase

          public void removeBeliefBase(BeliefBase beliefBase)

      Removes a belief base associated with this belief. If the belief base was the main belief base of this belief, this method sets a random belief base from the belief bases associated with this belief as the main belief base. If the removed belief base was the last belief base associated with this belief, the main belief base is set to null.
      Specified by:
        `removeBeliefBase` in interface `Belief<K,V>`
      Overrides:
        `removeBeliefBase` in class `AbstractBelief<K,V>`
      Parameters:
        `beliefBase` - the belief base to be removed.
      See Also:
        `AbstractBelief.removeBeliefBase(bdi4jade.belief.BeliefBase)`

    - #### setMainBeliefBase

          public void setMainBeliefBase(BeliefBase mainBeliefBase)

      Sets the main belief base of this belief. This method does not verify if the main belief base is one of the belief bases associated with this belief.
      Parameters:
        `mainBeliefBase` - the main belief base to set.

    - #### updateValue

          protected void updateValue(V value)

      This method throws a `NullPointerException`, as this operation is invalid for this belief. The value of this belief cannot be set as it is derived from other beliefs.
      Specified by:
        `updateValue` in class `AbstractBelief<K,V>`
      Parameters:
        `value` - the value to set.