private UndoableEdit createSuccessFailureEdit(Route route) {
OperationFlowActivity to = route.getTo().getActivity();
if (to instanceof Operation) {
return new NextOperationEdit(controller, route.getFrom(), route.getType(), null);
} else if (to instanceof EmailMessage) {
return new NextEmailEdit(controller, route.getFrom(), route.getType(), null);
} else {
throw new IllegalStateException("Unexpected target activity: " + to);
}
}