class RuleFlowProcessValidator implements ProcessValidator {

    public ProcessValidationError[] validateProcess(final RuleFlowProcess process) {
        final List<ProcessValidationError> errors = new ArrayList<>();

        if (process.getName() == null) {
            errors.add(new ProcessValidationErrorImpl(process,
                                                      "Process has no name."));
        }

        if (process.getId() == null || "".equals(process.getId())) {
            errors.add(new ProcessValidationErrorImpl(process,
                                                      "Process has no id."));
        }

        // check start node of process
        if (process.getStartNodes().isEmpty() && !process.isDynamic()) {
            errors.add(new ProcessValidationErrorImpl(process,
                                                      "Process has no start node."));
        }

        // Check end node of the process.
        if (process.getEndNodes().isEmpty() && !process.isDynamic()) {
            errors.add(new ProcessValidationErrorImpl(process,
                                                      "Process has no end node."));
        }

        validateNodes(process.getNodes(),
                      errors,
                      process);

        validateVariables(errors,
                          process);

        checkAllNodesConnectedToStart(process,
                                      process.isDynamic(),
                                      errors,
                                      process);

        return errors.toArray(new ProcessValidationError[errors.size()]);
    }

    private  RuleFlowProcessValidator();

}