T - the type of the belief value.public abstract class AbstractBelief<T> extends MetadataElementImpl implements Belief<T>
Belief interface. It
implements some of the interface methods, leaving some implementations to the
subclasses, mainly the choice of how the belief value is stored.
It is class observable by belief bases (BeliefBase), allowing the
observation on changes in the value of this belief.metadata| Modifier | Constructor and Description |
|---|---|
protected |
AbstractBelief()
The default constructor.
|
|
AbstractBelief(java.lang.String name)
Initializes a belief with its name.
|
|
AbstractBelief(java.lang.String name,
T value)
Initializes a belief with its name and an initial value.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addBeliefBase(BeliefBase beliefBase)
Adds a belief base that contains this belief.
|
boolean |
equals(java.lang.Object obj)
Returns true of the object is a belief and has the same name of this
belief.
|
java.util.Set<BeliefBase> |
getBeliefBases()
Returns the belief bases with which this belief is associated.
|
java.lang.String |
getName()
Returns the name of this belief.
|
int |
hashCode()
Returns the hash code of this belief name.
|
protected void |
notifyBeliefBases(BeliefEvent beliefEvent)
Notifies the belief bases with which this belief is associated that the
value of this belief has changed.
|
void |
removeBeliefBase(BeliefBase beliefBases)
Removes a belief base that does not contain this belief anymore.
|
protected void |
setName(java.lang.String name)
Sets the name of this belief.
|
void |
setValue(T value)
Sets a new value to the belief and notifies belief bases of changes on
this belief value.
|
java.lang.String |
toString()
Returns this belief as a string in the form:
"belief name = belief value".
|
protected abstract void |
updateValue(T value)
Sets the value of this belief.
|
getMetadata, getMetadata, hasMetadata, putMetadata, removeMetadataclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetMetadata, getMetadata, hasMetadata, putMetadata, removeMetadataprotected AbstractBelief()
public AbstractBelief(java.lang.String name)
name - the belief name.public AbstractBelief(java.lang.String name,
T value)
name - the belief name.value - the belief initial value.public void addBeliefBase(BeliefBase beliefBase)
BeliefaddBeliefBase in interface Belief<T>beliefBase - the belief base to be added.Belief.addBeliefBase(BeliefBase)public final boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - to object to be tested if it is equal to this belief.Object.equals(Object)public java.util.Set<BeliefBase> getBeliefBases()
BeliefgetBeliefBases in interface Belief<T>Belief.getBeliefBases()public final java.lang.String getName()
BeliefgetName in interface Belief<T>Belief.getName()public final int hashCode()
hashCode in class java.lang.ObjectObject.hashCode()protected void notifyBeliefBases(BeliefEvent beliefEvent)
beliefEvent - the BeliefEvent describing the change on this belief
valuepublic void removeBeliefBase(BeliefBase beliefBases)
BeliefremoveBeliefBase in interface Belief<T>beliefBases - the belief base to be removed.Belief.removeBeliefBase(BeliefBase)protected void setName(java.lang.String name)
name - the name to set.public final void setValue(T value)
setValue in interface Belief<T>value - the new value.Belief.setValue(Object)public java.lang.String toString()
toString in class java.lang.ObjectObject.toString()protected abstract void updateValue(T value)
setValue(Object) method.value - the value to set.