*/
boolean legalConfig = true; // let's be optimists
Map<EnterableState, Set<EnterableState>> counts = new HashMap<EnterableState, Set<EnterableState>>();
Set<EnterableState> scxmlCount = new HashSet<EnterableState>();
for (EnterableState es : states) {
EnterableState parent;
while ((parent = es.getParent()) != null) {
Set<EnterableState> cnt = counts.get(parent);
if (cnt == null) {
cnt = new HashSet<EnterableState>();
counts.put(parent, cnt);
}
cnt.add(es);
es = parent;
}
//top-level contribution
scxmlCount.add(es);
}
if (scxmlCount.size() > 1) {
errRep.onError(ErrorConstants.ILLEGAL_CONFIG, "Multiple top-level OR states active!", scxmlCount);
}
//Validate child counts:
for (Map.Entry<EnterableState, Set<EnterableState>> entry : counts.entrySet()) {
EnterableState es = entry.getKey();
Set<EnterableState> count = entry.getValue();
if (es instanceof Parallel) {
Parallel p = (Parallel) es;
if (count.size() < p.getChildren().size()) {
errRep.onError(ErrorConstants.ILLEGAL_CONFIG, "Not all AND states active for parallel " + p.getId(), entry);
legalConfig = false;
}
} else {
if (count.size() > 1) {
errRep.onError(ErrorConstants.ILLEGAL_CONFIG, "Multiple OR states active for state " + es.getId(), entry);
legalConfig = false;
}
}
count.clear(); //cleanup
}