class ReorderStepsUtils {

    boolean isStepOrderInvalid(List<AppendStep> appendSteps) {
        // Add all the columns created by steps as not available at the beginning
        final Set<String> notYetAvailableColumnsIds = appendSteps
                .stream()
                .flatMap(step -> step.getDiff().getCreatedColumns().stream())
                .collect(Collectors.toSet());

        return appendSteps.stream().noneMatch(step -> {
            for (Action action : step.getActions()) {
                final Map<String, String> parameters = action.getParameters();
                String[] columnIds = { parameters.get(ImplicitParameters.COLUMN_ID.getKey()) };
                if (ActionScope.MULTI_COLUMNS
                        .getDisplayName()
                        .equals(action.getParameters().get(ImplicitParameters.SCOPE.getKey()))) {
                    columnIds = ActionsUtils.extractColumnsId(parameters.get(COLUMN_IDS));
                }

                // remove the created columns from not available columns
                notYetAvailableColumnsIds.removeAll(step.getDiff().getCreatedColumns());

                for (String columnId : columnIds) {
                    // if the columns is no
                    if (notYetAvailableColumnsIds.contains(columnId)) {
                        return true;
                    }

                    // add removed columns to non available
                    if (StringUtils.equalsIgnoreCase(DeleteColumn.DELETE_COLUMN_ACTION_NAME, action.getName())) {
                        notYetAvailableColumnsIds.add(columnId);
                    }
                }
            }
            return false;
        });
    }

}