package lc.mecha.cred;

import java.util.Objects;

/**
 * This class provides connection information for a "generic" connection, including authorization
 * information in the form of a credential.
 *
 * @author Alex Leigh
 * @since mk11 mod47 (ZERO CONTRAST)
 */
public class CredentialConnection {
    private final String connectionString;
    private final Credential credential;

    public CredentialConnection(String connectionString, Credential credential) {
        this.connectionString = connectionString;
        this.credential = credential;
    }

    public String getUsername() {
        return credential.getUsername();
    }

    public String getPassword() {
        return credential.getPassword();
    }

    public String getConnectionString() {
        return connectionString;
    }

    public Credential getCredential() {
        return credential;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        CredentialConnection that = (CredentialConnection) o;
        return Objects.equals(connectionString, that.connectionString) &&
                Objects.equals(credential, that.credential);
    }

    @Override
    public int hashCode() {

        return Objects.hash(connectionString, credential);
    }

    @Override
    public String toString() {
        return "CredentialConnection{" +
                "connectionString='" + connectionString + '\'' +
                ", credential=" + credential +
                '}';
    }
}

