* @param allStates The current set of all active states in the state machine
*/
public void recordHistory(final Step step, final Set<EnterableState> states, final Set<EnterableState> allStates) {
for (EnterableState es : step.getExitSet()) {
if (es instanceof TransitionalState && ((TransitionalState)es).hasHistory()) {
TransitionalState ts = (TransitionalState)es;
Set<EnterableState> shallow = null;
Set<EnterableState> deep = null;
for (History h : ts.getHistory()) {
if (h.isDeep()) {
if (deep == null) {
//calculate deep history for a given state once
deep = new HashSet<EnterableState>();
for (EnterableState ott : states) {
if (ott.isDescendantOf(es)) {
deep.add(ott);
}
}
}
step.getNewHistoryConfigurations().put(h, deep);
} else {
if (shallow == null) {
//calculate shallow history for a given state once
shallow = new HashSet<EnterableState>(ts.getChildren());
shallow.retainAll(allStates);
}
step.getNewHistoryConfigurations().put(h, shallow);
}
}