ModuleDefinition moduleDefinition) {
RootModuleDefinition oldRootDefinition = moduleStateHolder.cloneRootModuleDefinition();
RootModuleDefinition newRootDefinition = moduleStateHolder.cloneRootModuleDefinition();
ModuleDefinition parent = moduleDefinition.getParentDefinition();
if (moduleDefinition instanceof RootModuleDefinition) {
newRootDefinition = (RootModuleDefinition) moduleDefinition;
}
else {
ModuleDefinition newParent = null;
if (parent == null) {
newParent = newRootDefinition;
}
else {
String parentName = parent.getName();
newParent = newRootDefinition.findChildDefinition(parentName, true);
if (newParent == null) {
throw new InvalidStateException("Unable to find parent module '" + parentName + "' in " + newRootDefinition);
}
}
newParent.add(moduleDefinition);
moduleDefinition.setParentDefinition(newParent);
}
TransitionSet transitions = calculator.getTransitions(oldRootDefinition, newRootDefinition);