if (loopCardinalityExpression != null) {
nrOfInstances = resolveLoopCardinality(execution);
} else if (collectionExpression != null) {
Object obj = collectionExpression.getValue(execution);
if (!(obj instanceof Collection)) {
throw new ActivitiException(collectionExpression.getExpressionText()+"' didn't resolve to a Collection");
}
nrOfInstances = ((Collection) obj).size();
} else if (collectionVariable != null) {
Object obj = execution.getVariable(collectionVariable);
if (!(obj instanceof Collection)) {
throw new ActivitiException("Variable " + collectionVariable+"' is not a Collection");
}
nrOfInstances = ((Collection) obj).size();
} else {
throw new ActivitiException("Couldn't resolve collection expression nor variable reference");
}
return nrOfInstances;
}