package be.iminds.ilabt.jfed.rspec.model.impl;

import be.iminds.ilabt.jfed.rspec.model.ExecuteAnsiblePlaybook;

import java.util.Objects;

/**
 * BasicExecuteAnsibleCookbook
 */
public class BasicExecuteAnsiblePlaybook implements ExecuteAnsiblePlaybook {
    private final String source;
    private final String outputFilename;

    public BasicExecuteAnsiblePlaybook(String source, String outputFilename) {
        this.source = source;
        this.outputFilename = outputFilename;
    }

    public BasicExecuteAnsiblePlaybook(ExecuteAnsiblePlaybook o) {
        this.source = o.getSource();
        this.outputFilename = o.getOutputFilename();
    }

    public String getSource() {
        return source;
    }

    public String getOutputFilename() {
        return outputFilename;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof ExecuteAnsiblePlaybook)) return false;

        ExecuteAnsiblePlaybook that = (ExecuteAnsiblePlaybook) o;

        if (outputFilename != null ? !Objects.equals(outputFilename, that.getOutputFilename()) : that.getOutputFilename() != null)
            return false;
        if (source != null ? !Objects.equals(source, that.getSource()) : that.getSource() != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = source != null ? source.hashCode() : 0;
        result = 31 * result + (outputFilename != null ? outputFilename.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "BasicExecuteAnsibleCookbook{" +
                "source='" + source + '\'' +
                (outputFilename == null ? "" : (", outputFilename='" + outputFilename + '\'')) +
                '}';
    }
}
