K - the type of the belief name or key.V - the type of the belief value.public abstract class AbstractBelief<K,V> extends MetadataElementImpl implements Belief<K,V>
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| Constructor and Description |
|---|
AbstractBelief()
The default constructor.
|
AbstractBelief(K name)
Initializes a belief with its name.
|
AbstractBelief(K name,
V 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.
|
java.lang.Object |
clone()
Clones a 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.
|
K |
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 beliefBase)
Removes a belief base that does not contain this belief anymore.
|
void |
setName(K name)
Sets the name of this belief.
|
void |
setValue(V 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(V value)
Sets the value of this belief.
|
getMetadata, getMetadata, hasMetadata, putMetadata, removeMetadatafinalize, getClass, notify, notifyAll, wait, wait, waitgetMetadata, getMetadata, hasMetadata, putMetadata, removeMetadatapublic AbstractBelief()
public AbstractBelief(K name)
name - the belief name.public void addBeliefBase(BeliefBase beliefBase)
BeliefaddBeliefBase in interface Belief<K,V>beliefBase - the belief base to be added.Belief.addBeliefBase(BeliefBase)public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
Beliefpublic 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<K,V>Belief.getBeliefBases()public final K getName()
BeliefgetName in interface Belief<K,V>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 beliefBase)
BeliefremoveBeliefBase in interface Belief<K,V>beliefBase - the belief base to be removed.Belief.removeBeliefBase(BeliefBase)public void setName(K name)
name - the name to set.public final void setValue(V value)
setValue in interface Belief<K,V>value - the new value.Belief.setValue(Object)public java.lang.String toString()
toString in class java.lang.ObjectObject.toString()protected abstract void updateValue(V value)
setValue(Object) method.value - the value to set.