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

import be.iminds.ilabt.jfed.rspec.model.DistributeSshKeypair;
import be.iminds.ilabt.jfed.util.GeniUrn;

import java.util.Objects;

/**
 * BasicExecuteAnsibleCookbook
 */
public class BasicDistributeSshKeypair implements DistributeSshKeypair {
    private final String location;
    private final GeniUrn user;

    public BasicDistributeSshKeypair(String location, GeniUrn user) {
        this.location = location;
        this.user = user;
    }

    public BasicDistributeSshKeypair(DistributeSshKeypair o){
        this.location = o.getLocation();
        this.user = o.getUser();
    }

    public String getLocation() {
        return location;
    }

    public GeniUrn getUser() {
        return user;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        BasicDistributeSshKeypair that = (BasicDistributeSshKeypair) o;

        if (location != null ? !Objects.equals(location, that.location) : that.location != null) return false;
        return user != null ? Objects.equals(user, that.user) : that.user == null;

    }

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

    @Override
    public String toString() {
        return "BasicDistributeSshKeypair{" +
                "location='" + location + '\'' +
                ", user=" + user +
                '}';
    }
}
