public class BeliefBase
extends java.lang.Object
implements java.io.Serializable
| Modifier | Constructor and Description |
|---|---|
protected |
BeliefBase()
The default constructor.
|
|
BeliefBase(Capability capability)
Creates a belief base associated with a capability.
|
|
BeliefBase(Capability capability,
java.util.Set<Belief<?,?>> beliefs)
Creates a belief base associated with a capability and adds the beliefs
in the provided belief set as the initial beliefs of this belief base.
|
| 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.
|
Belief<?,?> |
getBelief(java.lang.Object name)
Retrieves a belief from the belief base.
|
java.util.Set<BeliefListener> |
getBeliefListeners()
Returns all the current belief listeners of this belief base.
|
java.util.Collection<Belief<?,?>> |
getBeliefs()
Gets all beliefs of this belief base and the belief bases of the
whole-capabilities of the capability that this belief base belongs to.
|
java.util.Set<Belief<?,?>> |
getBeliefsAssignableFrom(java.lang.Class<?> beliefNameType)
Returns all beliefs whose name is of the given class or any other class
that is assignable to this class.
|
java.util.Set<Belief<?,?>> |
getBeliefsByType(java.lang.Class<?> beliefNameType)
Returns all beliefs whose name is of the given class.
|
Capability |
getCapability()
Returns the capability with which this belief base is associated.
|
java.util.Set<Belief<?,?>> |
getLocalBeliefs()
Gets all beliefs of this specific belief base.
|
java.util.Set<Belief<?,?>> |
getLocalBeliefsAssignableFrom(java.lang.Class<?> beliefNameType)
Returns all beliefs whose name is of the given class or any other class
that is assignable to this class.
|
java.util.Set<Belief<?,?>> |
getLocalBeliefsByType(java.lang.Class<?> beliefNameType)
Returns beliefs whose name is of the given class.
|
java.util.List<java.lang.Object> |
getLocalBeliefValues()
Returns a list of belief values from this belief base.
|
boolean |
hasBelief(java.lang.Object name)
Checks whether a belief is part of the belief base.
|
boolean |
hasBelief(java.lang.Object name,
java.lang.Object value)
Checks whether a belief is part of the belief base with an specific
value.
|
protected void |
notifyBeliefChanged(BeliefEvent beliefChanged)
Notifies the capability associated with this belief base that a belief
was modified.
|
Belief<?,?> |
removeBelief(java.lang.Object name)
Removes a belief from the belief base.
|
void |
removeBeliefListener(BeliefListener beliefListener)
Removes a belief listener.
|
protected void |
setCapability(Capability capability)
Associates a capability with this belief base.
|
int |
size()
Gets the size of this specific belief base (the number of beliefs).
|
java.lang.String |
toString()
Returns this belief base as a string in the form:
"Belief base of Capability ID = [ BELIEFS ]".
|
boolean |
updateBelief(java.lang.Object name,
java.lang.Object value)
Updates the value of a belief in the belief base.
|
protected BeliefBase()
public BeliefBase(Capability capability)
capability - the capability to which this belief base belongs.public BeliefBase(Capability capability, java.util.Set<Belief<?,?>> beliefs)
capability - the capability to which this belief base belongs.beliefs - the initial beliefs.public void addBelief(Belief<?,?> belief)
belief - the belief to be added.public void addBeliefListener(BeliefListener beliefListener)
beliefListener - the listener to be added.public void addOrUpdateBelief(Belief<?,?> belief)
belief - the belief to be added or updated.public Belief<?,?> getBelief(java.lang.Object name)
name - the name of the belief to be retrieved.public java.util.Set<BeliefListener> getBeliefListeners()
public java.util.Collection<Belief<?,?>> getBeliefs()
public java.util.Set<Belief<?,?>> getBeliefsAssignableFrom(java.lang.Class<?> beliefNameType)
beliefNameType - the class of the name of beliefs.public java.util.Set<Belief<?,?>> getBeliefsByType(java.lang.Class<?> beliefNameType)
beliefNameType - the class of the name of beliefs.public Capability getCapability()
public java.util.Set<Belief<?,?>> getLocalBeliefs()
public java.util.Set<Belief<?,?>> getLocalBeliefsAssignableFrom(java.lang.Class<?> beliefNameType)
beliefNameType - the class of the name of beliefs.public java.util.Set<Belief<?,?>> getLocalBeliefsByType(java.lang.Class<?> beliefNameType)
beliefNameType - the class of the name of beliefs.public java.util.List<java.lang.Object> getLocalBeliefValues()
public boolean hasBelief(java.lang.Object name)
name - the belief to be checkedpublic boolean hasBelief(java.lang.Object name,
java.lang.Object value)
name - the belief to be checkedvalue - the value to be checkedprotected void notifyBeliefChanged(BeliefEvent beliefChanged)
beliefChanged - the belief that was changedpublic Belief<?,?> removeBelief(java.lang.Object name)
name - the name of the belief to be removed.public void removeBeliefListener(BeliefListener beliefListener)
beliefListener - the listener to be removed.protected void setCapability(Capability capability)
capability - the capability to set.public int size()
public java.lang.String toString()
toString in class java.lang.ObjectObject.toString()public boolean updateBelief(java.lang.Object name,
java.lang.Object value)
name - the belief to be updated.value - the new value to the belief.