bdi4jade

Changes

Details

diff --git a/bdi-jade/src/bdi4jade/annotation/Belief.java b/bdi-jade/src/bdi4jade/annotation/Belief.java
index 4599bc5..ad4f5f8 100644
--- a/bdi-jade/src/bdi4jade/annotation/Belief.java
+++ b/bdi-jade/src/bdi4jade/annotation/Belief.java
@@ -47,9 +47,9 @@ import bdi4jade.plan.planbody.PlanBody;
 public @interface Belief {
 
 	/**
-	 * Returns the name of the belief to be retrieved from the belief base, in
-	 * case this annotation is used in a {@link PlanBody}. If no name is
-	 * provided, the attribute name is used.
+	 * Returns the name of the belief, if it is a string, to be retrieved from
+	 * the belief base, in case this annotation is used in a {@link PlanBody}.
+	 * If no name is provided, the attribute name is used.
 	 * 
 	 * @return the belief name.
 	 */
diff --git a/bdi-jade/src/bdi4jade/annotation/TransientBelief.java b/bdi-jade/src/bdi4jade/annotation/TransientBelief.java
index 9a3b5aa..31d9c7c 100644
--- a/bdi-jade/src/bdi4jade/annotation/TransientBelief.java
+++ b/bdi-jade/src/bdi4jade/annotation/TransientBelief.java
@@ -32,8 +32,9 @@ import bdi4jade.core.Capability;
 
 /**
  * This annotation allows to specify that an attribute of a {@link Capability}
- * is a belief value that should be added to the capability belief base. A name
- * for the belief may be given. If it is not provided, the field name is used.
+ * is a belief value that should be added to the capability belief base, whose
+ * key is a string. A name for the belief may be given, if it is a string. If it
+ * is not provided, the field name is used.
  * 
  * @author Ingrid Nunes
  */
diff --git a/bdi-jade/src/bdi4jade/annotation/TransientBeliefSet.java b/bdi-jade/src/bdi4jade/annotation/TransientBeliefSet.java
index 9d643a3..ac6f6e6 100644
--- a/bdi-jade/src/bdi4jade/annotation/TransientBeliefSet.java
+++ b/bdi-jade/src/bdi4jade/annotation/TransientBeliefSet.java
@@ -33,9 +33,10 @@ import bdi4jade.core.Capability;
 
 /**
  * This annotation allows to specify that an attribute of a {@link Capability}
- * is a belief set value that should be added to the capability belief base. A
- * name for the belief may be given. If it is not provided, the field name is
- * used. The annotated field should be of the type {@link Set}.
+ * is a belief set value that should be added to the capability belief base,
+ * whose key is a string. A name for the belief may be given, if it is a string.
+ * If it is not provided, the field name is used. The annotated field should be
+ * of the type {@link Set} .
  * 
  * @author Ingrid Nunes
  */
diff --git a/bdi-jade/src/bdi4jade/belief/AbstractBelief.java b/bdi-jade/src/bdi4jade/belief/AbstractBelief.java
index f69ce46..263f93b 100644
--- a/bdi-jade/src/bdi4jade/belief/AbstractBelief.java
+++ b/bdi-jade/src/bdi4jade/belief/AbstractBelief.java
@@ -37,25 +37,28 @@ import bdi4jade.event.BeliefEvent.Action;
  * It is class observable by belief bases ({@link BeliefBase}), allowing the
  * observation on changes in the value of this belief.
  * 
- * @author Ingrid Nunes
+ * @param <K>
+ *            the type of the belief name or key.
  * 
- * @param <T>
+ * @param <V>
  *            the type of the belief value.
+ * 
+ * @author Ingrid Nunes
  */
-public abstract class AbstractBelief<T> extends MetadataElementImpl implements
-		Belief<T> {
+public abstract class AbstractBelief<K, V> extends MetadataElementImpl
+		implements Belief<K, V> {
 
 	private static final long serialVersionUID = 5098122115249071355L;
 
 	private final Set<BeliefBase> beliefBases;
-	private String name;
+	private K name;
 
 	/**
 	 * The default constructor. It should be only used if persistence frameworks
 	 * are used.
 	 */
 	protected AbstractBelief() {
-		this.beliefBases = new HashSet<BeliefBase>();
+		this.beliefBases = new HashSet<>();
 	}
 
 	/**
@@ -64,7 +67,7 @@ public abstract class AbstractBelief<T> extends MetadataElementImpl implements
 	 * @param name
 	 *            the belief name.
 	 */
-	public AbstractBelief(String name) {
+	public AbstractBelief(K name) {
 		if (name == null)
 			throw new NullPointerException("Belief name must be not null.");
 		this.name = name;
@@ -79,7 +82,7 @@ public abstract class AbstractBelief<T> extends MetadataElementImpl implements
 	 * @param value
 	 *            the belief initial value.
 	 */
-	public AbstractBelief(String name, T value) {
+	public AbstractBelief(K name, V value) {
 		this(name);
 		updateValue(value);
 	}
@@ -102,8 +105,8 @@ public abstract class AbstractBelief<T> extends MetadataElementImpl implements
 	 */
 	@Override
 	public final boolean equals(Object obj) {
-		if (obj instanceof Belief<?>) {
-			Belief<?> b = (Belief<?>) obj;
+		if (obj instanceof Belief<?, ?>) {
+			Belief<?, ?> b = (Belief<?, ?>) obj;
 			return this.name.equals(b.getName());
 		}
 		return false;
@@ -119,7 +122,7 @@ public abstract class AbstractBelief<T> extends MetadataElementImpl implements
 	/**
 	 * @see Belief#getName()
 	 */
-	public final String getName() {
+	public final K getName() {
 		return name;
 	}
 
@@ -164,7 +167,7 @@ public abstract class AbstractBelief<T> extends MetadataElementImpl implements
 	 * @param name
 	 *            the name to set.
 	 */
-	protected void setName(String name) {
+	protected void setName(K name) {
 		this.name = name;
 	}
 
@@ -177,7 +180,7 @@ public abstract class AbstractBelief<T> extends MetadataElementImpl implements
 	 * 
 	 * @see Belief#setValue(Object)
 	 */
-	public final void setValue(T value) {
+	public final void setValue(V value) {
 		Object oldValue = getValue();
 		updateValue(value);
 		notifyBeliefBases(new BeliefEvent(this, Action.BELIEF_UPDATED, oldValue));
@@ -193,7 +196,7 @@ public abstract class AbstractBelief<T> extends MetadataElementImpl implements
 	 */
 	@Override
 	public String toString() {
-		return new StringBuffer(name).append(" = ").append(getValue())
+		return new StringBuffer().append(name).append(" = ").append(getValue())
 				.toString();
 	}
 
@@ -204,6 +207,6 @@ public abstract class AbstractBelief<T> extends MetadataElementImpl implements
 	 * @param value
 	 *            the value to set.
 	 */
-	protected abstract void updateValue(T value);
+	protected abstract void updateValue(V value);
 
 }
diff --git a/bdi-jade/src/bdi4jade/belief/AbstractBeliefSet.java b/bdi-jade/src/bdi4jade/belief/AbstractBeliefSet.java
index bf779b8..1c5a055 100644
--- a/bdi-jade/src/bdi4jade/belief/AbstractBeliefSet.java
+++ b/bdi-jade/src/bdi4jade/belief/AbstractBeliefSet.java
@@ -35,13 +35,16 @@ import bdi4jade.event.BeliefEvent.Action;
  * leaving some implementations to the subclasses, mainly the choice of how the
  * belief set values are stored.
  * 
- * @author Ingrid Nunes
+ * @param <K>
+ *            the type of the belief name or key.
  * 
- * @param <T>
+ * @param <V>
  *            the type of the belief set values.
+ * 
+ * @author Ingrid Nunes
  */
-public abstract class AbstractBeliefSet<T> extends AbstractBelief<Set<T>>
-		implements BeliefSet<T> {
+public abstract class AbstractBeliefSet<K, V> extends AbstractBelief<K, Set<V>>
+		implements BeliefSet<K, V> {
 
 	private static final long serialVersionUID = 8345025506647930L;
 
@@ -59,8 +62,8 @@ public abstract class AbstractBeliefSet<T> extends AbstractBelief<Set<T>>
 	 * @param name
 	 *            the name of this belief set.
 	 */
-	public AbstractBeliefSet(String name) {
-		super(name, new HashSet<T>());
+	public AbstractBeliefSet(K name) {
+		super(name, new HashSet<V>());
 	}
 
 	/**
@@ -71,9 +74,9 @@ public abstract class AbstractBeliefSet<T> extends AbstractBelief<Set<T>>
 	 * @param values
 	 *            the initial values of this belief set.
 	 */
-	public AbstractBeliefSet(String name, Set<T> values) {
+	public AbstractBeliefSet(K name, Set<V> values) {
 		super(name);
-		updateValue(new HashSet<T>(values));
+		updateValue(new HashSet<>(values));
 	}
 
 	/**
@@ -83,7 +86,7 @@ public abstract class AbstractBeliefSet<T> extends AbstractBelief<Set<T>>
 	 * @param value
 	 *            the value to be added.
 	 */
-	protected abstract void addSetValue(T value);
+	protected abstract void addSetValue(V value);
 
 	/**
 	 * Adds a value to the belief set and notifies belief bases of the addition
@@ -95,7 +98,7 @@ public abstract class AbstractBeliefSet<T> extends AbstractBelief<Set<T>>
 	 * @see BeliefSet#addValue(Object)
 	 */
 	@Override
-	public final void addValue(T value) {
+	public final void addValue(V value) {
 		if (!hasValue(value)) {
 			addSetValue(value);
 			notifyBeliefBases(new BeliefEvent(this,
@@ -111,7 +114,7 @@ public abstract class AbstractBeliefSet<T> extends AbstractBelief<Set<T>>
 	 *            the value to be added.
 	 * @return true if the value was removed, false otherwise.
 	 */
-	protected abstract boolean removeSetValue(T value);
+	protected abstract boolean removeSetValue(V value);
 
 	/**
 	 * Removes a value of the belief set and notifies belief bases of the
@@ -123,7 +126,7 @@ public abstract class AbstractBeliefSet<T> extends AbstractBelief<Set<T>>
 	 * @see BeliefSet#removeValue(Object)
 	 */
 	@Override
-	public final boolean removeValue(T value) {
+	public final boolean removeValue(V value) {
 		boolean removed = removeSetValue(value);
 		if (removed) {
 			notifyBeliefBases(new BeliefEvent(this,
diff --git a/bdi-jade/src/bdi4jade/belief/Belief.java b/bdi-jade/src/bdi4jade/belief/Belief.java
index 2694ce2..05960d6 100644
--- a/bdi-jade/src/bdi4jade/belief/Belief.java
+++ b/bdi-jade/src/bdi4jade/belief/Belief.java
@@ -30,18 +30,24 @@ import java.util.Set;
 import bdi4jade.core.MetadataElement;
 
 /**
- * This interface represents a belief of the belief base. It has a name and a
- * value associate with it. It is parameterized by the type of the belief value.
+ * This interface represents a belief of the belief base. It has a name (or a
+ * key) and a value associate with it. It is parameterized by the types of the
+ * name/key and value. For example, a name may be an object representing a
+ * propositional formula, and the value is a boolean indicating whether the
+ * formula is true or false.
  * 
  * It extends the {@link MetadataElement} interface, allowing to associate
  * metadata with beliefs.
  * 
- * @param <T>
+ * @param <K>
+ *            the type of the belief name or key.
+ * 
+ * @param <V>
  *            the type of the belief value.
  * 
  * @author Ingrid Nunes
  */
-public interface Belief<T> extends MetadataElement, Serializable, Concept {
+public interface Belief<K, V> extends MetadataElement, Serializable, Concept {
 
 	/**
 	 * Adds a belief base that contains this belief. The agent whose capability
@@ -64,14 +70,14 @@ public interface Belief<T> extends MetadataElement, Serializable, Concept {
 	 * 
 	 * @return the string that is the belief name.
 	 */
-	public String getName();
+	public K getName();
 
 	/**
 	 * Gets the current value of the belief.
 	 * 
 	 * @return the belief value.
 	 */
-	public T getValue();
+	public V getValue();
 
 	/**
 	 * Removes a belief base that does not contain this belief anymore. The
@@ -89,6 +95,6 @@ public interface Belief<T> extends MetadataElement, Serializable, Concept {
 	 * @param value
 	 *            the new value.
 	 */
-	public void setValue(T value);
+	public void setValue(V value);
 
 }
diff --git a/bdi-jade/src/bdi4jade/belief/BeliefBase.java b/bdi-jade/src/bdi4jade/belief/BeliefBase.java
index b5f953b..fd9e7a7 100644
--- a/bdi-jade/src/bdi4jade/belief/BeliefBase.java
+++ b/bdi-jade/src/bdi4jade/belief/BeliefBase.java
@@ -49,7 +49,8 @@ public class BeliefBase implements Serializable {
 	private static final long serialVersionUID = -6411530721625492882L;
 
 	private final Set<BeliefListener> beliefListeners;
-	private final Map<String, Belief<?>> beliefs;
+	private final Map<Object, Belief<?, ?>> beliefs;
+	private final Map<Class<?>, Set<Belief<?, ?>>> beliefsByType;
 	private Capability capability;
 
 	/**
@@ -57,8 +58,9 @@ public class BeliefBase implements Serializable {
 	 * are used.
 	 */
 	protected BeliefBase() {
-		this.beliefListeners = new HashSet<BeliefListener>();
-		this.beliefs = new HashMap<String, Belief<?>>();
+		this.beliefListeners = new HashSet<>();
+		this.beliefs = new HashMap<>();
+		this.beliefsByType = new HashMap<>();
 	}
 
 	/**
@@ -80,16 +82,17 @@ public class BeliefBase implements Serializable {
 	 * @param beliefs
 	 *            the initial beliefs.
 	 */
-	public BeliefBase(final Capability capability, Set<Belief<?>> beliefs) {
+	public BeliefBase(final Capability capability, Set<Belief<?, ?>> beliefs) {
 		if (capability == null)
 			throw new NullPointerException("Capability must be not null.");
 
 		this.capability = capability;
-		this.beliefListeners = new HashSet<BeliefListener>();
-		this.beliefs = new HashMap<String, Belief<?>>();
+		this.beliefListeners = new HashSet<>();
+		this.beliefs = new HashMap<>();
+		this.beliefsByType = new HashMap<>();
 		if (beliefs != null) {
-			for (Belief<?> belief : beliefs) {
-				this.beliefs.put(belief.getName(), belief);
+			for (Belief<?, ?> belief : beliefs) {
+				putBelief(belief);
 			}
 		}
 	}
@@ -100,10 +103,10 @@ public class BeliefBase implements Serializable {
 	 * @param belief
 	 *            the belief to be added.
 	 */
-	public void addBelief(Belief<?> belief) {
+	public void addBelief(Belief<?, ?> belief) {
 		if (!hasBelief(belief.getName())) {
 			belief.addBeliefBase(this);
-			this.beliefs.put(belief.getName(), belief);
+			putBelief(belief);
 			notifyBeliefChanged(new BeliefEvent(belief, Action.BELIEF_ADDED));
 		} else {
 			throw new BeliefAlreadyExistsException(belief);
@@ -127,7 +130,7 @@ public class BeliefBase implements Serializable {
 	 * @param belief
 	 *            the belief to be added or updated.
 	 */
-	public void addOrUpdateBelief(Belief<?> belief) {
+	public void addOrUpdateBelief(Belief<?, ?> belief) {
 		if (hasBelief(belief.getName())) {
 			updateBelief(belief.getName(), belief.getValue());
 		} else {
@@ -141,8 +144,8 @@ public class BeliefBase implements Serializable {
 	 * 
 	 * @return the beliefs of this capability and all of its whole-capabilities.
 	 */
-	public Collection<Belief<?>> getAllBeliefs() {
-		Collection<Belief<?>> beliefs = new LinkedList<Belief<?>>();
+	public Collection<Belief<?, ?>> getAllBeliefs() {
+		Collection<Belief<?, ?>> beliefs = new LinkedList<>();
 		getAllBeliefs(beliefs);
 		return beliefs;
 	}
@@ -154,7 +157,7 @@ public class BeliefBase implements Serializable {
 	 * @param beliefs
 	 *            the set to which beliefs are added.
 	 */
-	private void getAllBeliefs(final Collection<Belief<?>> beliefs) {
+	private void getAllBeliefs(final Collection<Belief<?, ?>> beliefs) {
 		beliefs.addAll(this.beliefs.values());
 		if (capability.getWholeCapability() != null) {
 			capability.getWholeCapability().getBeliefBase()
@@ -163,6 +166,64 @@ public class BeliefBase implements Serializable {
 	}
 
 	/**
+	 * Returns all beliefs whose name is of the given class or any other class
+	 * that is assignable to this class. It also searches beliefs in belief
+	 * bases of whole capabilities.
+	 * 
+	 * @param beliefNameType
+	 *            the class of the name of beliefs.
+	 * @return the set of beliefs assignable from the given class.
+	 */
+	public Set<Belief<?, ?>> getAllBeliefsAssignableFrom(Class<?> beliefNameType) {
+		Set<Belief<?, ?>> beliefs = new HashSet<>();
+		getAllBeliefsAssignableFrom(beliefNameType, beliefs);
+		return beliefs;
+	}
+
+	private void getAllBeliefsAssignableFrom(Class<?> beliefNameType,
+			Collection<Belief<?, ?>> beliefs) {
+		for (Class<?> beliefSupertype : beliefsByType.keySet()) {
+			if (beliefSupertype.isAssignableFrom(beliefNameType)) {
+				Set<Belief<?, ?>> beliefsOfType = beliefsByType
+						.get(beliefSupertype);
+				beliefs.addAll(beliefsOfType);
+			}
+		}
+
+		if (capability.getWholeCapability() != null) {
+			capability.getWholeCapability().getBeliefBase()
+					.getAllBeliefsAssignableFrom(beliefNameType, beliefs);
+		}
+	}
+
+	/**
+	 * Returns all beliefs whose name is of the given class. It also searches
+	 * beliefs in belief bases of whole capabilities.
+	 * 
+	 * @param beliefNameType
+	 *            the class of the name of beliefs.
+	 * @return the set of beliefs of the given class.
+	 */
+	public Set<Belief<?, ?>> getAllBeliefsByType(Class<?> beliefNameType) {
+		Set<Belief<?, ?>> beliefs = new HashSet<>();
+		getAllBeliefsByType(beliefNameType, beliefs);
+		return beliefs;
+	}
+
+	private void getAllBeliefsByType(Class<?> beliefNameType,
+			Collection<Belief<?, ?>> beliefs) {
+		Set<Belief<?, ?>> beliefsOfType = beliefsByType.get(beliefNameType);
+		if (beliefsOfType != null) {
+			beliefs.addAll(beliefsOfType);
+		}
+
+		if (capability.getWholeCapability() != null) {
+			capability.getWholeCapability().getBeliefBase()
+					.getAllBeliefsByType(beliefNameType, beliefs);
+		}
+	}
+
+	/**
 	 * Retrieves a belief from the belief base. If this belief base does not
 	 * contain it, the method checks whole-capabilities' belief base
 	 * recursively.
@@ -171,8 +232,8 @@ public class BeliefBase implements Serializable {
 	 *            the name of the belief to be retrieved.
 	 * @return the belief, or null if no belief is found.
 	 */
-	public Belief<?> getBelief(String name) {
-		Belief<?> belief = this.beliefs.get(name);
+	public Belief<?, ?> getBelief(Object name) {
+		Belief<?, ?> belief = this.beliefs.get(name);
 		if (belief == null && capability.getWholeCapability() != null) {
 			belief = capability.getWholeCapability().getBeliefBase()
 					.getBelief(name);
@@ -186,7 +247,7 @@ public class BeliefBase implements Serializable {
 	 * @return the belief listeners.
 	 */
 	public Set<BeliefListener> getBeliefListeners() {
-		return new HashSet<BeliefListener>(beliefListeners);
+		return new HashSet<>(beliefListeners);
 	}
 
 	/**
@@ -194,8 +255,44 @@ public class BeliefBase implements Serializable {
 	 * 
 	 * @return the beliefs
 	 */
-	public Set<Belief<?>> getBeliefs() {
-		return new HashSet<Belief<?>>(beliefs.values());
+	public Set<Belief<?, ?>> getBeliefs() {
+		return new HashSet<>(beliefs.values());
+	}
+
+	/**
+	 * Returns all beliefs whose name is of the given class or any other class
+	 * that is assignable to this class.
+	 * 
+	 * @param beliefNameType
+	 *            the class of the name of beliefs.
+	 * @return the set of beliefs assignable from the given class.
+	 */
+	public Set<Belief<?, ?>> getBeliefsAssignableFrom(Class<?> beliefNameType) {
+		Set<Belief<?, ?>> beliefs = new HashSet<>();
+		for (Class<?> beliefsubtype : beliefsByType.keySet()) {
+			if (beliefNameType.isAssignableFrom(beliefsubtype)) {
+				Set<Belief<?, ?>> beliefsOfType = beliefsByType
+						.get(beliefsubtype);
+				beliefs.addAll(beliefsOfType);
+			}
+		}
+		return beliefs;
+	}
+
+	/**
+	 * Returns all beliefs whose name is of the given class.
+	 * 
+	 * @param beliefNameType
+	 *            the class of the name of beliefs.
+	 * @return the set of beliefs of the given class.
+	 */
+	public Set<Belief<?, ?>> getBeliefsByType(Class<?> beliefNameType) {
+		Set<Belief<?, ?>> beliefs = new HashSet<>();
+		Set<Belief<?, ?>> beliefsOfType = beliefsByType.get(beliefNameType);
+		if (beliefsOfType != null) {
+			beliefs.addAll(beliefsOfType);
+		}
+		return beliefs;
 	}
 
 	/**
@@ -204,8 +301,8 @@ public class BeliefBase implements Serializable {
 	 * @return the beliefValues
 	 */
 	public List<Object> getBeliefValues() {
-		List<Object> beliefValues = new ArrayList<Object>(beliefs.size());
-		for (Belief<?> belief : beliefs.values())
+		List<Object> beliefValues = new ArrayList<>(beliefs.size());
+		for (Belief<?, ?> belief : beliefs.values())
 			beliefValues.add(belief.getValue());
 		return beliefValues;
 	}
@@ -228,7 +325,7 @@ public class BeliefBase implements Serializable {
 	 *            the belief to be checked
 	 * @return true if the belief base contains the belief.
 	 */
-	public boolean hasBelief(String name) {
+	public boolean hasBelief(Object name) {
 		boolean hasBelief = this.beliefs.containsKey(name);
 		if (!hasBelief && capability.getWholeCapability() != null) {
 			hasBelief = capability.getWholeCapability().getBeliefBase()
@@ -254,6 +351,17 @@ public class BeliefBase implements Serializable {
 		}
 	}
 
+	private void putBelief(Belief<?, ?> belief) {
+		Class<?> beliefNameType = belief.getName().getClass();
+		Set<Belief<?, ?>> beliefTypeSet = beliefsByType.get(beliefNameType);
+		if (beliefTypeSet == null) {
+			beliefTypeSet = new HashSet<>();
+			beliefsByType.put(beliefNameType, beliefTypeSet);
+		}
+		beliefTypeSet.add(belief);
+		this.beliefs.put(belief.getName(), belief);
+	}
+
 	/**
 	 * Removes a belief from the belief base. If this belief base does not
 	 * contain it, the method checks whole-capabilities' belief base recursively
@@ -264,9 +372,15 @@ public class BeliefBase implements Serializable {
 	 * @return the belief was removed, null if it is not part of the belief
 	 *         base.
 	 */
-	public Belief<?> removeBelief(String name) {
-		Belief<?> belief = this.beliefs.remove(name);
+	public Belief<?, ?> removeBelief(Object name) {
+		Belief<?, ?> belief = this.beliefs.remove(name);
 		if (belief != null) {
+			Class<?> beliefNameType = belief.getName().getClass();
+			Set<Belief<?, ?>> beliefTypeSet = beliefsByType.get(beliefNameType);
+			assert beliefTypeSet.remove(belief);
+			if (beliefTypeSet.isEmpty()) {
+				beliefsByType.remove(beliefNameType);
+			}
 			belief.removeBeliefBase(this);
 			notifyBeliefChanged(new BeliefEvent(belief, Action.BELIEF_REMOVED));
 		} else {
@@ -342,7 +456,7 @@ public class BeliefBase implements Serializable {
 	 * @return true if the belief was updated.
 	 */
 	@SuppressWarnings("unchecked")
-	public boolean updateBelief(String name, Object value) {
+	public boolean updateBelief(Object name, Object value) {
 		Belief belief = this.beliefs.get(name);
 		if (belief != null) {
 			belief.setValue(value);
diff --git a/bdi-jade/src/bdi4jade/belief/BeliefSet.java b/bdi-jade/src/bdi4jade/belief/BeliefSet.java
index 7bf0fce..7a6b082 100644
--- a/bdi-jade/src/bdi4jade/belief/BeliefSet.java
+++ b/bdi-jade/src/bdi4jade/belief/BeliefSet.java
@@ -29,12 +29,15 @@ import java.util.Set;
  * This interface represents a belief that has a set of values associated with
  * it.
  * 
- * @author Ingrid Nunes
+ * @param <K>
+ *            the type of the belief name or key.
  * 
- * @param <T>
+ * @param <V>
  *            the type of the belief set values.
+ * 
+ * @author Ingrid Nunes
  */
-public interface BeliefSet<T> extends Belief<Set<T>> {
+public interface BeliefSet<K, V> extends Belief<K, Set<V>> {
 
 	/**
 	 * Adds a new value to this belief set.
@@ -42,7 +45,7 @@ public interface BeliefSet<T> extends Belief<Set<T>> {
 	 * @param value
 	 *            the value to be added.
 	 */
-	public void addValue(T value);
+	public void addValue(V value);
 
 	/**
 	 * Checks whether this belief set has the provided value.
@@ -51,14 +54,14 @@ public interface BeliefSet<T> extends Belief<Set<T>> {
 	 *            the value to be checked.
 	 * @return true if the belief set contains this value, false otherwise.
 	 */
-	public boolean hasValue(T value);
+	public boolean hasValue(V value);
 
 	/**
 	 * Returns an iterator for this belief set.
 	 * 
 	 * @return the iterator to iterate the values of the belief set.
 	 */
-	public Iterator<T> iterator();
+	public Iterator<V> iterator();
 
 	/**
 	 * Removes a value from this belief set.
@@ -67,6 +70,6 @@ public interface BeliefSet<T> extends Belief<Set<T>> {
 	 *            the value to be removed.
 	 * @return true if the value was removed, false otherwise.
 	 */
-	public boolean removeValue(T value);
+	public boolean removeValue(V value);
 
 }
diff --git a/bdi-jade/src/bdi4jade/belief/PersistentBelief.java b/bdi-jade/src/bdi4jade/belief/PersistentBelief.java
index 68c4d7a..1e1a02c 100644
--- a/bdi-jade/src/bdi4jade/belief/PersistentBelief.java
+++ b/bdi-jade/src/bdi4jade/belief/PersistentBelief.java
@@ -30,11 +30,11 @@ package bdi4jade.belief;
  * @author Ingrid Nunes
  * 
  */
-public class PersistentBelief<T> extends AbstractBelief<T> {
+public class PersistentBelief<K, V> extends AbstractBelief<K, V> {
 
 	private static final long serialVersionUID = 2893517209462636003L;
 
-	protected T value;
+	protected V value;
 
 	/**
 	 * Initializes a belief with its name.
@@ -42,7 +42,7 @@ public class PersistentBelief<T> extends AbstractBelief<T> {
 	 * @param name
 	 *            the belief name.
 	 */
-	public PersistentBelief(String name) {
+	public PersistentBelief(K name) {
 		super(name);
 	}
 
@@ -52,7 +52,7 @@ public class PersistentBelief<T> extends AbstractBelief<T> {
 	 * @see bdi4jade.belief.Belief#getValue()
 	 */
 	@Override
-	public T getValue() {
+	public V getValue() {
 		// TODO Future: PersistentBelief.getValue()
 		throw new RuntimeException("Not implemented yet!");
 	}
@@ -62,7 +62,7 @@ public class PersistentBelief<T> extends AbstractBelief<T> {
 	 * 
 	 * @see bdi4jade.belief.Belief#setValue(java.lang.Object)
 	 */
-	protected void updateValue(T value) {
+	protected void updateValue(V value) {
 		// TODO Future: PersistentBelief.setValue(T value)
 		throw new RuntimeException("Not implemented yet!");
 	}
diff --git a/bdi-jade/src/bdi4jade/belief/PropositionalBelief.java b/bdi-jade/src/bdi4jade/belief/PropositionalBelief.java
new file mode 100644
index 0000000..3443a5b
--- /dev/null
+++ b/bdi-jade/src/bdi4jade/belief/PropositionalBelief.java
@@ -0,0 +1,38 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2011  Ingrid Nunes
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+// 
+// To contact the authors:
+// http://inf.ufrgs.br/prosoft/bdi4jade/
+//
+//----------------------------------------------------------------------------
+
+package bdi4jade.belief;
+
+/**
+ * This interface represents a belief that is a propositional logic statement.
+ * The information is represented as an object of type K, which has a boolean
+ * value to indicate if the formula is true or false. Null may represents the
+ * absence of knowledge if the formula is true or false.
+ * 
+ * @param <T>
+ *            the type of the propositional statement.
+ * 
+ * @author Ingrid Nunes
+ */
+public interface PropositionalBelief<K> extends Belief<K, Boolean> {
+
+}
diff --git a/bdi-jade/src/bdi4jade/belief/TransientBelief.java b/bdi-jade/src/bdi4jade/belief/TransientBelief.java
index cd4080d..b2846ed 100644
--- a/bdi-jade/src/bdi4jade/belief/TransientBelief.java
+++ b/bdi-jade/src/bdi4jade/belief/TransientBelief.java
@@ -31,11 +31,11 @@ package bdi4jade.belief;
  * @param <T>
  *            the type of the belief value.
  */
-public class TransientBelief<T> extends AbstractBelief<T> {
+public class TransientBelief<K, V> extends AbstractBelief<K, V> {
 
 	private static final long serialVersionUID = 2893517209462636003L;
 
-	protected T value;
+	protected V value;
 
 	/**
 	 * The default constructor. It should be only used if persistence frameworks
@@ -51,7 +51,7 @@ public class TransientBelief<T> extends AbstractBelief<T> {
 	 * @param name
 	 *            the belief name.
 	 */
-	public TransientBelief(String name) {
+	public TransientBelief(K name) {
 		super(name);
 	}
 
@@ -63,7 +63,7 @@ public class TransientBelief<T> extends AbstractBelief<T> {
 	 * @param value
 	 *            the initial belief value.
 	 */
-	public TransientBelief(String name, T value) {
+	public TransientBelief(K name, V value) {
 		super(name);
 		this.value = value;
 	}
@@ -72,7 +72,7 @@ public class TransientBelief<T> extends AbstractBelief<T> {
 	 * @see bdi4jade.belief.Belief#getValue()
 	 */
 	@Override
-	public T getValue() {
+	public V getValue() {
 		return this.value;
 	}
 
@@ -80,7 +80,7 @@ public class TransientBelief<T> extends AbstractBelief<T> {
 	 * @see bdi4jade.belief.AbstractBelief#updateValue(java.lang.Object)
 	 */
 	@Override
-	protected void updateValue(T value) {
+	protected void updateValue(V value) {
 		this.value = value;
 	}
 
diff --git a/bdi-jade/src/bdi4jade/belief/TransientBeliefSet.java b/bdi-jade/src/bdi4jade/belief/TransientBeliefSet.java
index 99904a3..b662751 100644
--- a/bdi-jade/src/bdi4jade/belief/TransientBeliefSet.java
+++ b/bdi-jade/src/bdi4jade/belief/TransientBeliefSet.java
@@ -36,12 +36,11 @@ import java.util.Set;
  * @param <T>
  *            the type of the belief set values.
  */
-public class TransientBeliefSet<T> extends AbstractBeliefSet<T> implements
-		BeliefSet<T> {
+public class TransientBeliefSet<K, V> extends AbstractBeliefSet<K, V> {
 
 	private static final long serialVersionUID = 8345025506647930L;
 
-	private Set<T> value;
+	private Set<V> value;
 
 	/**
 	 * The default constructor. It should be only used if persistence frameworks
@@ -57,8 +56,8 @@ public class TransientBeliefSet<T> extends AbstractBeliefSet<T> implements
 	 * @param name
 	 *            the name of this belief set.
 	 */
-	public TransientBeliefSet(String name) {
-		super(name, new HashSet<T>());
+	public TransientBeliefSet(K name) {
+		super(name, new HashSet<V>());
 	}
 
 	/**
@@ -69,7 +68,7 @@ public class TransientBeliefSet<T> extends AbstractBeliefSet<T> implements
 	 * @param values
 	 *            the initial values of this belief set.
 	 */
-	public TransientBeliefSet(String name, Set<T> values) {
+	public TransientBeliefSet(K name, Set<V> values) {
 		super(name, values);
 	}
 
@@ -77,7 +76,7 @@ public class TransientBeliefSet<T> extends AbstractBeliefSet<T> implements
 	 * @see bdi4jade.belief.AbstractBeliefSet#addSetValue(Object)
 	 */
 	@Override
-	protected void addSetValue(T value) {
+	protected void addSetValue(V value) {
 		this.value.add(value);
 	}
 
@@ -85,7 +84,7 @@ public class TransientBeliefSet<T> extends AbstractBeliefSet<T> implements
 	 * @see bdi4jade.belief.Belief#getValue()
 	 */
 	@Override
-	public Set<T> getValue() {
+	public Set<V> getValue() {
 		return value;
 	}
 
@@ -93,7 +92,7 @@ public class TransientBeliefSet<T> extends AbstractBeliefSet<T> implements
 	 * @see bdi4jade.belief.BeliefSet#hasValue(java.lang.Object)
 	 */
 	@Override
-	public boolean hasValue(T value) {
+	public boolean hasValue(V value) {
 		return this.value.contains(value);
 	}
 
@@ -101,7 +100,7 @@ public class TransientBeliefSet<T> extends AbstractBeliefSet<T> implements
 	 * @see bdi4jade.belief.BeliefSet#iterator()
 	 */
 	@Override
-	public Iterator<T> iterator() {
+	public Iterator<V> iterator() {
 		return this.value.iterator();
 	}
 
@@ -109,7 +108,7 @@ public class TransientBeliefSet<T> extends AbstractBeliefSet<T> implements
 	 * @see bdi4jade.belief.AbstractBeliefSet#removeSetValue(Object)
 	 */
 	@Override
-	protected boolean removeSetValue(T value) {
+	protected boolean removeSetValue(V value) {
 		return this.value.remove(value);
 	}
 
@@ -117,7 +116,7 @@ public class TransientBeliefSet<T> extends AbstractBeliefSet<T> implements
 	 * @see bdi4jade.belief.AbstractBelief#updateValue(java.lang.Object)
 	 */
 	@Override
-	protected void updateValue(Set<T> value) {
+	protected void updateValue(Set<V> value) {
 		this.value = value;
 	}
 
diff --git a/bdi-jade/src/bdi4jade/belief/TransientPropositionalBelief.java b/bdi-jade/src/bdi4jade/belief/TransientPropositionalBelief.java
new file mode 100644
index 0000000..ee8113d
--- /dev/null
+++ b/bdi-jade/src/bdi4jade/belief/TransientPropositionalBelief.java
@@ -0,0 +1,36 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2011  Ingrid Nunes
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+// 
+// To contact the authors:
+// http://inf.ufrgs.br/prosoft/bdi4jade/
+//
+//----------------------------------------------------------------------------
+
+package bdi4jade.belief;
+
+/**
+ * This class extends the {@link TransientBelief} class and represents a
+ * transient propositional belief, which is not persisted in a permanent memory.
+ * 
+ * @author Ingrid Nunes
+ */
+public class TransientPropositionalBelief<K> extends
+		TransientBelief<K, Boolean> implements PropositionalBelief<K> {
+
+	private static final long serialVersionUID = -2315938302480821432L;
+
+}
diff --git a/bdi-jade/src/bdi4jade/core/AbstractBDIAgent.java b/bdi-jade/src/bdi4jade/core/AbstractBDIAgent.java
index 22776ba..b319071 100644
--- a/bdi-jade/src/bdi4jade/core/AbstractBDIAgent.java
+++ b/bdi-jade/src/bdi4jade/core/AbstractBDIAgent.java
@@ -488,9 +488,9 @@ public abstract class AbstractBDIAgent extends Agent implements BDIAgent {
 	 * @see bdi4jade.core.BDIAgent#getBeliefs()
 	 */
 	@Override
-	public final Collection<Belief<?>> getBeliefs() {
+	public final Collection<Belief<?, ?>> getBeliefs() {
 		synchronized (aggregatedCapabilities) {
-			Collection<Belief<?>> beliefs = new LinkedList<Belief<?>>();
+			Collection<Belief<?, ?>> beliefs = new LinkedList<>();
 			for (Capability capability : capabilities) {
 				beliefs.addAll(capability.getBeliefBase().getBeliefs());
 			}
diff --git a/bdi-jade/src/bdi4jade/core/BDIAgent.java b/bdi-jade/src/bdi4jade/core/BDIAgent.java
index 6575ac9..f1bdd9a 100644
--- a/bdi-jade/src/bdi4jade/core/BDIAgent.java
+++ b/bdi-jade/src/bdi4jade/core/BDIAgent.java
@@ -153,7 +153,7 @@ public interface BDIAgent {
 	 * 
 	 * @return the collection of all beliefs of this agent.
 	 */
-	public Collection<Belief<?>> getBeliefs();
+	public Collection<Belief<?, ?>> getBeliefs();
 
 	/**
 	 * Returns all goal listeners.
diff --git a/bdi-jade/src/bdi4jade/core/Capability.java b/bdi-jade/src/bdi4jade/core/Capability.java
index 8930021..06f4619 100644
--- a/bdi-jade/src/bdi4jade/core/Capability.java
+++ b/bdi-jade/src/bdi4jade/core/Capability.java
@@ -105,7 +105,7 @@ public class Capability implements Serializable {
 	 *            the initial set of plans to be added to the plan library of
 	 *            this capability.
 	 */
-	public Capability(Set<Belief<?>> initialBeliefs, Set<Plan> initialPlans) {
+	public Capability(Set<Belief<?, ?>> initialBeliefs, Set<Plan> initialPlans) {
 		this(null, null, initialBeliefs, null, initialPlans);
 	}
 
@@ -141,7 +141,7 @@ public class Capability implements Serializable {
 	 *            this capability.
 	 */
 	protected Capability(String id, BeliefBase beliefBase,
-			Set<Belief<?>> initialBeliefs, PlanLibrary planLibrary,
+			Set<Belief<?, ?>> initialBeliefs, PlanLibrary planLibrary,
 			Set<Plan> initialPlans) {
 		this.log = LogFactory.getLog(getClass());
 		this.intentions = new LinkedList<>();
@@ -198,7 +198,7 @@ public class Capability implements Serializable {
 	 *            the initial set of plans to be added to the plan library of
 	 *            this capability.
 	 */
-	public Capability(String id, Set<Belief<?>> initialBeliefs,
+	public Capability(String id, Set<Belief<?, ?>> initialBeliefs,
 			Set<Plan> initialPlans) {
 		this(id, null, initialBeliefs, null, initialPlans);
 	}
@@ -220,7 +220,7 @@ public class Capability implements Serializable {
 			try {
 				if (field.isAnnotationPresent(bdi4jade.annotation.Belief.class)) {
 					if (Belief.class.isAssignableFrom(field.getType())) {
-						Belief<?> belief = (Belief<?>) field.get(this);
+						Belief<?, ?> belief = (Belief<?, ?>) field.get(this);
 						this.getBeliefBase().addBelief(belief);
 					} else {
 						throw new ClassCastException("Field " + field.getName()
diff --git a/bdi-jade/src/bdi4jade/event/BeliefEvent.java b/bdi-jade/src/bdi4jade/event/BeliefEvent.java
index dabb028..bfbfe3d 100644
--- a/bdi-jade/src/bdi4jade/event/BeliefEvent.java
+++ b/bdi-jade/src/bdi4jade/event/BeliefEvent.java
@@ -46,7 +46,7 @@ public class BeliefEvent implements AgentAction {
 
 	private Action action;
 	private Object args;
-	private Belief<?> belief;
+	private Belief<?, ?> belief;
 
 	/**
 	 * Default constructor.
@@ -61,7 +61,7 @@ public class BeliefEvent implements AgentAction {
 	 * @param belief
 	 *            the belief over which the event has occurred.
 	 */
-	public BeliefEvent(Belief<?> belief) {
+	public BeliefEvent(Belief<?, ?> belief) {
 		this(belief, Action.BELIEF_UPDATED);
 	}
 
@@ -73,7 +73,7 @@ public class BeliefEvent implements AgentAction {
 	 * @param action
 	 *            the action performed.
 	 */
-	public BeliefEvent(Belief<?> belief, Action action) {
+	public BeliefEvent(Belief<?, ?> belief, Action action) {
 		this(belief, action, null);
 	}
 
@@ -87,7 +87,7 @@ public class BeliefEvent implements AgentAction {
 	 * @param args
 	 *            an argument passed for this action.
 	 */
-	public BeliefEvent(Belief<?> belief, Action action, Object args) {
+	public BeliefEvent(Belief<?, ?> belief, Action action, Object args) {
 		this.belief = belief;
 		this.action = action;
 		this.args = args;
@@ -116,7 +116,7 @@ public class BeliefEvent implements AgentAction {
 	 * 
 	 * @return the belief
 	 */
-	public Belief<?> getBelief() {
+	public Belief<?, ?> getBelief() {
 		return belief;
 	}
 
@@ -146,7 +146,7 @@ public class BeliefEvent implements AgentAction {
 	 * @param belief
 	 *            the belief to set.
 	 */
-	public void setBelief(Belief<?> belief) {
+	public void setBelief(Belief<?, ?> belief) {
 		this.belief = belief;
 	}
 
diff --git a/bdi-jade/src/bdi4jade/exception/BeliefAlreadyExistsException.java b/bdi-jade/src/bdi4jade/exception/BeliefAlreadyExistsException.java
index 83dd2a5..c48d4ad 100644
--- a/bdi-jade/src/bdi4jade/exception/BeliefAlreadyExistsException.java
+++ b/bdi-jade/src/bdi4jade/exception/BeliefAlreadyExistsException.java
@@ -34,7 +34,7 @@ public class BeliefAlreadyExistsException extends RuntimeException {
 
 	private static final long serialVersionUID = -6082968354395705561L;
 
-	private Belief<?> belief;
+	private Belief<?, ?> belief;
 
 	/**
 	 * Creates a new instance of BeliefAlreadyExistsException.
@@ -42,14 +42,14 @@ public class BeliefAlreadyExistsException extends RuntimeException {
 	 * @param belief
 	 *            the belief that already exists.
 	 */
-	public BeliefAlreadyExistsException(Belief<?> belief) {
+	public BeliefAlreadyExistsException(Belief<?, ?> belief) {
 		this.belief = belief;
 	}
 
 	/**
 	 * @return the belief
 	 */
-	public Belief<?> getBelief() {
+	public Belief<?, ?> getBelief() {
 		return belief;
 	}
 
diff --git a/bdi-jade/src/bdi4jade/extension/planselection/utilitybased/SoftgoalPreferences.java b/bdi-jade/src/bdi4jade/extension/planselection/utilitybased/SoftgoalPreferences.java
index 8cc79d7..840bf49 100644
--- a/bdi-jade/src/bdi4jade/extension/planselection/utilitybased/SoftgoalPreferences.java
+++ b/bdi-jade/src/bdi4jade/extension/planselection/utilitybased/SoftgoalPreferences.java
@@ -34,7 +34,8 @@ import bdi4jade.goal.Softgoal;
  * 
  * @author Ingrid Nunes
  */
-public class SoftgoalPreferences extends TransientBelief<Map<Softgoal, Double>> {
+public class SoftgoalPreferences extends
+		TransientBelief<String, Map<Softgoal, Double>> {
 
 	public static final String NAME = SoftgoalPreferences.class.getSimpleName();
 
diff --git a/bdi-jade/src/bdi4jade/goal/BeliefGoal.java b/bdi-jade/src/bdi4jade/goal/BeliefGoal.java
index 19b6a5d..31f3914 100644
--- a/bdi-jade/src/bdi4jade/goal/BeliefGoal.java
+++ b/bdi-jade/src/bdi4jade/goal/BeliefGoal.java
@@ -32,11 +32,11 @@ import bdi4jade.belief.BeliefBase;
  * 
  * @author Ingrid Nunes
  */
-public class BeliefGoal implements Goal {
+public class BeliefGoal<K> implements Goal {
 
 	private static final long serialVersionUID = 2493877854717226283L;
 
-	private String beliefName;
+	private K beliefName;
 
 	/**
 	 * Creates a new BeliefGoal with the provided belief name.
@@ -44,7 +44,7 @@ public class BeliefGoal implements Goal {
 	 * @param beliefName
 	 *            the belief name.
 	 */
-	public BeliefGoal(String beliefName) {
+	public BeliefGoal(K beliefName) {
 		this.beliefName = beliefName;
 	}
 
@@ -54,7 +54,7 @@ public class BeliefGoal implements Goal {
 	 * @return the belief name.
 	 */
 	@Parameter(direction = Direction.IN)
-	public String getBeliefName() {
+	public K getBeliefName() {
 		return beliefName;
 	}
 
diff --git a/bdi-jade/src/bdi4jade/goal/BeliefSetValueGoal.java b/bdi-jade/src/bdi4jade/goal/BeliefSetValueGoal.java
index 2d8e22d..91552f3 100644
--- a/bdi-jade/src/bdi4jade/goal/BeliefSetValueGoal.java
+++ b/bdi-jade/src/bdi4jade/goal/BeliefSetValueGoal.java
@@ -35,7 +35,7 @@ import bdi4jade.belief.BeliefSet;
  * 
  * @author Ingrid Nunes
  */
-public class BeliefSetValueGoal<T> extends BeliefValueGoal<T> {
+public class BeliefSetValueGoal<K, V> extends BeliefValueGoal<K, V> {
 
 	private static final long serialVersionUID = 2493877854717226283L;
 
@@ -49,7 +49,7 @@ public class BeliefSetValueGoal<T> extends BeliefValueGoal<T> {
 	 * @param value
 	 *            the value that is target of this goal.
 	 */
-	public BeliefSetValueGoal(String beliefSetName, T value) {
+	public BeliefSetValueGoal(K beliefSetName, V value) {
 		super(beliefSetName, value);
 	}
 
@@ -64,7 +64,7 @@ public class BeliefSetValueGoal<T> extends BeliefValueGoal<T> {
 	@SuppressWarnings("unchecked")
 	@Override
 	public boolean isAchieved(BeliefBase beliefBase) {
-		BeliefSet<T> beliefSet = (BeliefSet<T>) beliefBase
+		BeliefSet<K, V> beliefSet = (BeliefSet<K, V>) beliefBase
 				.getBelief(getBeliefName());
 		if (beliefSet == null) {
 			return false;
diff --git a/bdi-jade/src/bdi4jade/goal/BeliefValueGoal.java b/bdi-jade/src/bdi4jade/goal/BeliefValueGoal.java
index 0bba114..c93ccaa 100644
--- a/bdi-jade/src/bdi4jade/goal/BeliefValueGoal.java
+++ b/bdi-jade/src/bdi4jade/goal/BeliefValueGoal.java
@@ -37,11 +37,11 @@ import bdi4jade.belief.BeliefBase;
  * 
  * @author Ingrid Nunes
  */
-public class BeliefValueGoal<T> extends BeliefGoal {
+public class BeliefValueGoal<K, V> extends BeliefGoal<K> {
 
 	private static final long serialVersionUID = 2493877854717226283L;
 
-	private T value;
+	private V value;
 
 	/**
 	 * Creates a new BeliefValueGoal with the provided belief name and a value.
@@ -53,7 +53,7 @@ public class BeliefValueGoal<T> extends BeliefGoal {
 	 * @param value
 	 *            the value that is target of this goal.
 	 */
-	public BeliefValueGoal(String beliefName, T value) {
+	public BeliefValueGoal(K beliefName, V value) {
 		super(beliefName);
 		this.value = value;
 	}
@@ -64,7 +64,7 @@ public class BeliefValueGoal<T> extends BeliefGoal {
 	 * @return the belief value.
 	 */
 	@Parameter(direction = Direction.IN)
-	public T getValue() {
+	public V getValue() {
 		return value;
 	}
 
@@ -79,7 +79,7 @@ public class BeliefValueGoal<T> extends BeliefGoal {
 	 */
 	@Override
 	public boolean isAchieved(BeliefBase beliefBase) {
-		Belief<?> belief = (Belief<?>) beliefBase.getBelief(getBeliefName());
+		Belief<?, ?> belief = beliefBase.getBelief(getBeliefName());
 		if (belief == null) {
 			return false;
 		} else {
diff --git a/bdi-jade/src/bdi4jade/goal/GoalTemplateFactory.java b/bdi-jade/src/bdi4jade/goal/GoalTemplateFactory.java
index f9bc84f..a1ee0cb 100644
--- a/bdi-jade/src/bdi4jade/goal/GoalTemplateFactory.java
+++ b/bdi-jade/src/bdi4jade/goal/GoalTemplateFactory.java
@@ -40,11 +40,11 @@ public abstract class GoalTemplateFactory {
 	 * @return the goal template that checks if the goal is a {@link BeliefGoal}
 	 *         with the given name.
 	 */
-	public static GoalTemplate beliefGoal(final String beliefName) {
+	public static GoalTemplate beliefGoal(final Object beliefName) {
 		return new GoalTemplate() {
 			public boolean match(Goal goal) {
 				if (goal instanceof BeliefGoal) {
-					BeliefGoal bg = (BeliefGoal) goal;
+					BeliefGoal<?> bg = (BeliefGoal<?>) goal;
 					return bg.getBeliefName().equals(beliefName);
 				}
 				return false;
@@ -69,12 +69,12 @@ public abstract class GoalTemplateFactory {
 	 *         {@link BeliefSetValueGoal} with the given name and value of the
 	 *         given type.
 	 */
-	public static GoalTemplate beliefSetTypeGoal(final String beliefName,
+	public static GoalTemplate beliefSetTypeGoal(final Object beliefName,
 			final Class<?> beliefValueClass) {
 		return new GoalTemplate() {
 			public boolean match(Goal goal) {
 				if (goal instanceof BeliefSetValueGoal) {
-					BeliefSetValueGoal<?> bg = (BeliefSetValueGoal<?>) goal;
+					BeliefSetValueGoal<?, ?> bg = (BeliefSetValueGoal<?, ?>) goal;
 					return bg.getBeliefName().equals(beliefName)
 							&& beliefValueClass.isInstance(bg.getValue());
 				}
@@ -100,12 +100,12 @@ public abstract class GoalTemplateFactory {
 	 * @return the goal template that checks if the goal is a
 	 *         {@link BeliefSetValueGoal} with the given name and value.
 	 */
-	public static GoalTemplate beliefSetValueGoal(final String beliefName,
+	public static GoalTemplate beliefSetValueGoal(final Object beliefName,
 			final Object beliefValue) {
 		return new GoalTemplate() {
 			public boolean match(Goal goal) {
 				if (goal instanceof BeliefSetValueGoal) {
-					BeliefSetValueGoal<?> bg = (BeliefSetValueGoal<?>) goal;
+					BeliefSetValueGoal<?, ?> bg = (BeliefSetValueGoal<?, ?>) goal;
 					return bg.getBeliefName().equals(beliefName)
 							&& beliefValue.equals(bg.getValue());
 				}
@@ -131,12 +131,12 @@ public abstract class GoalTemplateFactory {
 	 *         {@link BeliefValueGoal} with the given name and value of the
 	 *         given type.
 	 */
-	public static GoalTemplate beliefTypeGoal(final String beliefName,
+	public static GoalTemplate beliefTypeGoal(final Object beliefName,
 			final Class<?> beliefValueClass) {
 		return new GoalTemplate() {
 			public boolean match(Goal goal) {
 				if (goal instanceof BeliefValueGoal) {
-					BeliefValueGoal<?> bg = (BeliefValueGoal<?>) goal;
+					BeliefValueGoal<?, ?> bg = (BeliefValueGoal<?, ?>) goal;
 					return bg.getBeliefName().equals(beliefName)
 							&& beliefValueClass.isInstance(bg.getValue());
 				}
@@ -167,7 +167,7 @@ public abstract class GoalTemplateFactory {
 		return new GoalTemplate() {
 			public boolean match(Goal goal) {
 				if (goal instanceof BeliefValueGoal) {
-					BeliefValueGoal<?> bg = (BeliefValueGoal<?>) goal;
+					BeliefValueGoal<?, ?> bg = (BeliefValueGoal<?, ?>) goal;
 					return bg.getBeliefName().equals(beliefName)
 							&& beliefValue.equals(bg.getValue());
 				}
@@ -210,11 +210,11 @@ public abstract class GoalTemplateFactory {
 	 * @return the goal template that checks if the goal is a
 	 *         {@link BeliefValueGoal} with the given name and null value.
 	 */
-	public static GoalTemplate nullBeliefValueGoal(final String beliefName) {
+	public static GoalTemplate nullBeliefValueGoal(final Object beliefName) {
 		return new GoalTemplate() {
 			public boolean match(Goal goal) {
 				if (goal instanceof BeliefValueGoal) {
-					BeliefValueGoal<?> bg = (BeliefValueGoal<?>) goal;
+					BeliefValueGoal<?, ?> bg = (BeliefValueGoal<?, ?>) goal;
 					return bg.getBeliefName().equals(beliefName)
 							&& bg.getValue() == null;
 				}
diff --git a/bdi-jade/src/bdi4jade/plan/PlanLibrary.java b/bdi-jade/src/bdi4jade/plan/PlanLibrary.java
index a534e9b..9d9355a 100644
--- a/bdi-jade/src/bdi4jade/plan/PlanLibrary.java
+++ b/bdi-jade/src/bdi4jade/plan/PlanLibrary.java
@@ -42,7 +42,6 @@ import bdi4jade.plan.planbody.SequentialGoalPlanBody;
  * 
  * @author Ingrid Nunes
  */
-// TODO Future: PlanLibrary - create indexes to optimize plan matches
 public class PlanLibrary implements Serializable {
 
 	private static final long serialVersionUID = 3038533629659859857L;
diff --git a/bdi-jade/src/bdi4jade/util/ReflectionUtils.java b/bdi-jade/src/bdi4jade/util/ReflectionUtils.java
index b371666..9659964 100644
--- a/bdi-jade/src/bdi4jade/util/ReflectionUtils.java
+++ b/bdi-jade/src/bdi4jade/util/ReflectionUtils.java
@@ -195,7 +195,7 @@ public abstract class ReflectionUtils {
 							if (beliefName == null || "".equals(beliefName)) {
 								beliefName = field.getName();
 							}
-							Belief<?> belief = capability.getBeliefBase()
+							Belief<?, ?> belief = capability.getBeliefBase()
 									.getBelief(beliefName);
 							field.set(planBody, belief);
 						} else {
diff --git a/bdi-jade-test/src/bdi4jade/examples/BDI4JADEExamplesPanel.java b/bdi-jade-test/src/bdi4jade/examples/BDI4JADEExamplesPanel.java
index fecb7d7..60b61d0 100644
--- a/bdi-jade-test/src/bdi4jade/examples/BDI4JADEExamplesPanel.java
+++ b/bdi-jade-test/src/bdi4jade/examples/BDI4JADEExamplesPanel.java
@@ -86,7 +86,7 @@ public class BDI4JADEExamplesPanel extends JPanel {
 			target.add(new On(Thing.BLOCK_2, Thing.BLOCK_3));
 			target.add(new On(Thing.BLOCK_1, Thing.BLOCK_2));
 
-			blocksWorldAgent.addGoal(new BeliefValueGoal<Set<On>>(
+			blocksWorldAgent.addGoal(new BeliefValueGoal<String, Set<On>>(
 					BlocksWorldCapability.BELIEF_ON, target), this);
 		}
 
diff --git a/bdi-jade-test/src/bdi4jade/examples/blocksworld/BlocksWorldCapability.java b/bdi-jade-test/src/bdi4jade/examples/blocksworld/BlocksWorldCapability.java
index 629c3d7..61c5d4c 100644
--- a/bdi-jade-test/src/bdi4jade/examples/blocksworld/BlocksWorldCapability.java
+++ b/bdi-jade-test/src/bdi4jade/examples/blocksworld/BlocksWorldCapability.java
@@ -92,7 +92,8 @@ public class BlocksWorldCapability extends Capability {
 			AchieveOnPlanBody.class);
 
 	@Belief
-	private BeliefSet<Clear> clear = new TransientBeliefSet<>(BELIEF_CLEAR);
+	private BeliefSet<String, Clear> clear = new TransientBeliefSet<>(
+			BELIEF_CLEAR);
 
 	@Plan
 	private bdi4jade.plan.Plan clearPlan = new DefaultPlan(
@@ -100,7 +101,7 @@ public class BlocksWorldCapability extends Capability {
 			ClearPlanBody.class);
 
 	@Belief
-	private BeliefSet<On> on = new TransientBeliefSet<>(BELIEF_ON);
+	private BeliefSet<String, On> on = new TransientBeliefSet<>(BELIEF_ON);
 
 	@Plan
 	private bdi4jade.plan.Plan performMovePlan;
diff --git a/bdi-jade-test/src/bdi4jade/examples/blocksworld/BlocksWorldView.java b/bdi-jade-test/src/bdi4jade/examples/blocksworld/BlocksWorldView.java
index e4ad86a..19798ec 100644
--- a/bdi-jade-test/src/bdi4jade/examples/blocksworld/BlocksWorldView.java
+++ b/bdi-jade-test/src/bdi4jade/examples/blocksworld/BlocksWorldView.java
@@ -68,12 +68,23 @@ public class BlocksWorldView extends JPanel implements BeliefListener {
 		this.add(onTableTextArea);
 	}
 
+	@Override
+	public void eventOccurred(BeliefEvent beliefEvent) {
+		log.debug(beliefEvent);
+		if (Action.BELIEF_SET_VALUE_REMOVED.equals(beliefEvent.getAction()))
+			return;
+
+		// Ignore inconsistent states
+		updateText(generateStateText());
+		repaint();
+	}
+
 	private State generateStateText() {
 		State state = new State();
 
-		BeliefSet<On> onBelief = (BeliefSet<On>) beliefBase
+		BeliefSet<String, On> onBelief = (BeliefSet<String, On>) beliefBase
 				.getBelief(BlocksWorldCapability.BELIEF_ON);
-		BeliefSet<Clear> clearBelief = (BeliefSet<Clear>) beliefBase
+		BeliefSet<String, Clear> clearBelief = (BeliefSet<String, Clear>) beliefBase
 				.getBelief(BlocksWorldCapability.BELIEF_CLEAR);
 
 		List<Thing> tops = new ArrayList<>(2);
@@ -111,7 +122,7 @@ public class BlocksWorldView extends JPanel implements BeliefListener {
 	}
 
 	private Thing getNext(Thing thing) {
-		BeliefSet<On> onBelief = (BeliefSet<On>) beliefBase
+		BeliefSet<String, On> onBelief = (BeliefSet<String, On>) beliefBase
 				.getBelief(BlocksWorldCapability.BELIEF_ON);
 		for (On on : onBelief.getValue()) {
 			if (on.getThing1().equals(thing))
@@ -129,17 +140,6 @@ public class BlocksWorldView extends JPanel implements BeliefListener {
 		return s.toString();
 	}
 
-	@Override
-	public void eventOccurred(BeliefEvent beliefEvent) {
-		log.debug(beliefEvent);
-		if (Action.BELIEF_SET_VALUE_REMOVED.equals(beliefEvent.getAction()))
-			return;
-
-		// Ignore inconsistent states
-		updateText(generateStateText());
-		repaint();
-	}
-
 	private void updateText(final State state) {
 		JOptionPane.showMessageDialog(null, "Proceed?");
 		stack1TextArea.setText(state.stack1);
diff --git a/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/AchieveOnPlanBody.java b/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/AchieveOnPlanBody.java
index 0e99d81..22406db 100644
--- a/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/AchieveOnPlanBody.java
+++ b/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/AchieveOnPlanBody.java
@@ -54,12 +54,12 @@ public class AchieveOnPlanBody extends BeliefGoalPlanBody {
 	public void execute() {
 		switch (step) {
 		case CLEAR_1:
-			dispatchSubgoalAndListen(new BeliefSetValueGoal<Clear>(
+			dispatchSubgoalAndListen(new BeliefSetValueGoal<String, Clear>(
 					BlocksWorldCapability.BELIEF_CLEAR, new Clear(thing1)));
 			step = Step.CLEAR_2;
 		case CLEAR_2:
 			if (isSubgoalAchieved()) {
-				dispatchSubgoalAndListen(new BeliefSetValueGoal<Clear>(
+				dispatchSubgoalAndListen(new BeliefSetValueGoal<String, Clear>(
 						BlocksWorldCapability.BELIEF_CLEAR, new Clear(thing2)));
 				step = Step.PERFORM_MOVE;
 			}
diff --git a/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/ClearPlanBody.java b/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/ClearPlanBody.java
index e7cc927..c93d816 100644
--- a/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/ClearPlanBody.java
+++ b/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/ClearPlanBody.java
@@ -45,7 +45,7 @@ public class ClearPlanBody extends BeliefGoalPlanBody {
 
 	private boolean goalDispatched;
 	@Belief
-	private BeliefSet<On> on;
+	private BeliefSet<String, On> on;
 	private Thing thing;
 
 	@Override
@@ -54,7 +54,7 @@ public class ClearPlanBody extends BeliefGoalPlanBody {
 			for (int i = 0; i < Thing.THINGS.length; i++) {
 				Thing t = Thing.THINGS[i];
 				if (on.hasValue(new On(t, thing))) {
-					dispatchSubgoalAndListen(new BeliefSetValueGoal<On>(
+					dispatchSubgoalAndListen(new BeliefSetValueGoal<String, On>(
 							BlocksWorldCapability.BELIEF_ON, new On(t,
 									Thing.TABLE)));
 					this.goalDispatched = true;
diff --git a/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/PerformMovePlanBody.java b/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/PerformMovePlanBody.java
index 7a75775..49ddf31 100644
--- a/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/PerformMovePlanBody.java
+++ b/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/PerformMovePlanBody.java
@@ -41,9 +41,9 @@ public class PerformMovePlanBody extends AbstractPlanBody {
 	private static final long serialVersionUID = -5919677537834351951L;
 
 	@Belief(name = BlocksWorldCapability.BELIEF_CLEAR)
-	private BeliefSet<Clear> clearSet;
+	private BeliefSet<String, Clear> clearSet;
 	@Belief(name = BlocksWorldCapability.BELIEF_ON)
-	private BeliefSet<On> onSet;
+	private BeliefSet<String, On> onSet;
 	private Thing thing1;
 	private Thing thing2;
 
diff --git a/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/TopLevelPlanBody.java b/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/TopLevelPlanBody.java
index d47b8dc..a8a5b3f 100644
--- a/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/TopLevelPlanBody.java
+++ b/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/TopLevelPlanBody.java
@@ -59,7 +59,7 @@ public class TopLevelPlanBody extends BeliefGoalPlanBody {
 		}
 		// Dispatch the next subgoal, if there are subgoals left
 		if (counter < target.length) {
-			dispatchSubgoalAndListen(new BeliefSetValueGoal<On>(
+			dispatchSubgoalAndListen(new BeliefSetValueGoal<String, On>(
 					BlocksWorldCapability.BELIEF_ON, target[counter]));
 		}
 		counter++;
diff --git a/bdi-jade-test/src/bdi4jade/examples/capabilities/TestPlanBody.java b/bdi-jade-test/src/bdi4jade/examples/capabilities/TestPlanBody.java
index e393e05..e8d57f4 100644
--- a/bdi-jade-test/src/bdi4jade/examples/capabilities/TestPlanBody.java
+++ b/bdi-jade-test/src/bdi4jade/examples/capabilities/TestPlanBody.java
@@ -41,18 +41,18 @@ public class TestPlanBody extends AbstractPlanBody {
 	private static final long serialVersionUID = -9039447524062487795L;
 
 	@bdi4jade.annotation.Belief
-	private Belief<String> bottomBelief;
+	private Belief<String, String> bottomBelief;
 	@bdi4jade.annotation.Belief
-	private Belief<String> middle1Belief;
+	private Belief<String, String> middle1Belief;
 	@bdi4jade.annotation.Belief
-	private Belief<String> middle1ParentBelief;
+	private Belief<String, String> middle1ParentBelief;
 	@bdi4jade.annotation.Belief
-	private Belief<String> middle2Belief;
+	private Belief<String, String> middle2Belief;
 	private TestStep step;
 	@bdi4jade.annotation.Belief
-	private Belief<String> topBelief;
+	private Belief<String, String> topBelief;
 	@bdi4jade.annotation.Belief
-	private Belief<String> topParentBelief;
+	private Belief<String, String> topParentBelief;
 
 	public void action() {
 		switch (step) {
diff --git a/bdi-jade-test/src/bdi4jade/examples/ping/PingPlanBody.java b/bdi-jade-test/src/bdi4jade/examples/ping/PingPlanBody.java
index 3589887..4ea7571 100644
--- a/bdi-jade-test/src/bdi4jade/examples/ping/PingPlanBody.java
+++ b/bdi-jade-test/src/bdi4jade/examples/ping/PingPlanBody.java
@@ -40,9 +40,9 @@ public class PingPlanBody extends AbstractPlanBody {
 	private int counter;
 	private MessageTemplate mt;
 	@bdi4jade.annotation.Belief
-	private Belief<String> neighbour;
+	private Belief<String, String> neighbour;
 	@bdi4jade.annotation.Belief
-	private Belief<Integer> pingTimes;
+	private Belief<String, Integer> pingTimes;
 	private boolean sent;
 
 	@Override
diff --git a/bdi-jade-test/src/bdi4jade/examples/ping/PingPongCapability.java b/bdi-jade-test/src/bdi4jade/examples/ping/PingPongCapability.java
index 3351522..30b6e32 100644
--- a/bdi-jade-test/src/bdi4jade/examples/ping/PingPongCapability.java
+++ b/bdi-jade-test/src/bdi4jade/examples/ping/PingPongCapability.java
@@ -36,30 +36,32 @@ import bdi4jade.plan.Plan;
  */
 public class PingPongCapability extends Capability {
 
-	private static final long serialVersionUID = -4800805796961540570L;
-
 	@GoalOwner(capability = PingPongCapability.class)
 	public static class PingGoal implements Goal {
 		private static final long serialVersionUID = -7733145369836002329L;
 	}
 
-	@bdi4jade.annotation.Belief
-	Belief<String> neighbour;
+	private static final long serialVersionUID = -4800805796961540570L;
 
 	@bdi4jade.annotation.Belief
-	Belief<Integer> pingTimes;
+	Belief<String, String> neighbour;
 
 	@bdi4jade.annotation.Plan
 	private Plan pingPlan = new DefaultPlan(PingGoal.class, PingPlanBody.class);
 
+	@bdi4jade.annotation.Belief
+	Belief<String, Integer> pingTimes;
+
 	@bdi4jade.annotation.Plan
 	private Plan pongPlan = new DefaultPlan(
 			MessageTemplate.MatchContent(PingPlanBody.MSG_CONTENT),
 			PongPlanBody.class);
 
 	public PingPongCapability(String neighbour, int pingTimes) {
-		this.neighbour = new TransientBelief<String>("neighbour", neighbour);
-		this.pingTimes = new TransientBelief<Integer>("pingTimes", pingTimes);
+		this.neighbour = new TransientBelief<String, String>("neighbour",
+				neighbour);
+		this.pingTimes = new TransientBelief<String, Integer>("pingTimes",
+				pingTimes);
 	}
 
 }
diff --git a/bdi-jade-test/src/bdi4jade/examples/planselection/TransportationAgent.java b/bdi-jade-test/src/bdi4jade/examples/planselection/TransportationAgent.java
index d3f9c19..9db4fcd 100644
--- a/bdi-jade-test/src/bdi4jade/examples/planselection/TransportationAgent.java
+++ b/bdi-jade-test/src/bdi4jade/examples/planselection/TransportationAgent.java
@@ -61,7 +61,7 @@ public class TransportationAgent extends SingleCapabilityAgent {
 			getCapability().getPlanLibrary().addPlan(plan);
 		}
 		getCapability().getBeliefBase().addBelief(
-				new TransientBelief<GenericValueFunction<Integer>>(
+				new TransientBelief<String, GenericValueFunction<Integer>>(
 						SATISFACTION, new GenericValueFunction<Integer>()));
 	}
 
diff --git a/bdi-jade-test/src/bdi4jade/examples/planselection/TransportationPlanBody.java b/bdi-jade-test/src/bdi4jade/examples/planselection/TransportationPlanBody.java
index 0e2a531..23930dc 100644
--- a/bdi-jade-test/src/bdi4jade/examples/planselection/TransportationPlanBody.java
+++ b/bdi-jade-test/src/bdi4jade/examples/planselection/TransportationPlanBody.java
@@ -134,7 +134,7 @@ public class TransportationPlanBody extends AbstractPlanBody {
 	public void onStart() {
 		this.log = LogFactory.getLog(this.getClass());
 		this.plan = (TransportationPlan) getPlan();
-		this.satisfaction = ((TransientBelief<GenericValueFunction<Integer>>) getBeliefBase()
+		this.satisfaction = ((TransientBelief<String, GenericValueFunction<Integer>>) getBeliefBase()
 				.getBelief(TransportationAgent.SATISFACTION)).getValue();
 		this.preferences = (SoftgoalPreferences) getBeliefBase().getBelief(
 				SoftgoalPreferences.NAME);