if (continuousResidentNode.getMFrag() == null || continuousResidentNode.getMFrag().getMultiEntityBayesianNetwork() == null) {
throw new IllegalArgumentException(continuousResidentNode + " is inconsistent: it is not associated with any MTheory");
}
// extract the "Number" entity from the continuousResidentNode. The possible values of continuous resident nodes are assumed to be individuals of entity "Number"
ObjectEntity numberType = null;
try {
numberType = this.getMultiEntityBayesianNetwork().getObjectEntityContainer().getObjectEntityByName(continuousResidentNode.NUMBER_ENTITY_NAME);
} catch (Exception e) {
throw new IllegalArgumentException("The type of " + continuousResidentNode +" is not a " + continuousResidentNode.NUMBER_ENTITY_NAME +", and also could not extract the type from its MTheory.", e);
}
if (numberType == null) {
// let's assure we never have numberType == null
throw new IllegalArgumentException("The type of " + continuousResidentNode +" is not a " + continuousResidentNode.NUMBER_ENTITY_NAME +", and also could not extract the type from its MTheory.");
}
// check whether the value is already recorded as a possible value of numberType. If so, reuse it
ObjectEntityInstance state = numberType.getInstanceByName(String.valueOf(value));
if (state == null) {
// this is a new value. Insert it
try {
state = numberType.addInstance(String.valueOf(value));
continuousResidentNode.getMFrag().getMultiEntityBayesianNetwork().getObjectEntityContainer().addEntityInstance(state);
} catch (TypeException e) {
throw new IllegalArgumentException("Cannnot use " + value + " as a possible value of " + continuousResidentNode,e);
} catch (EntityInstanceAlreadyExistsException e) {
e.printStackTrace();