package be.iminds.ilabt.jfed.experimenter_gui.editor.rspec_validation;

import be.iminds.ilabt.jfed.rspec.model.javafx_impl.FXModelRspec;
import be.iminds.ilabt.jfed.rspec.rspec_source.RequestRspecSource;

import javax.annotation.Nonnull;

/**
 * User: twalcari
 * Date: 1/22/2015
 * Time: 16:42
 */
public class RspecValidationResult {
    private final RequestRspecSource replacementRequestRspecSource;
    private final boolean abort;

    public RspecValidationResult(@Nonnull RequestRspecSource replacementRequestRspecSource, boolean abort) {
        this.replacementRequestRspecSource = replacementRequestRspecSource;
        this.abort = abort;
    }

    public RspecValidationResult(FXModelRspec fxModelRspec) {
        this.replacementRequestRspecSource = new RequestRspecSource(fxModelRspec);
        this.abort = false;
    }

    /**
     * This boolean tells the RspecValidationEngine whether the ValidationResult means that the action which
     * prompted the validation (running the experiment, switching to graphical editor, etc.) must be
     * aborted (= true), or is either fixed or should be ignored (= false).
     * <p/>
     * In case abort == false, and a replacementRequestRspec is provided, this Rspec should ALWAYS replace the inputted
     * one before moving on.
     *
     * @return
     */
    public boolean isAbort() {
        return abort;
    }

    @Nonnull
    public RequestRspecSource getReplacementRequestRspecSource() {
        return replacementRequestRspecSource;
    }
}
