package com.usoftchina.uas.office.entity;

import com.usoftchina.uas.office.jdbc.DataSourceBean;
import com.usoftchina.uas.office.util.StringUtils;

import java.util.Objects;

/**
 * @author yingp
 * @date 2020/1/15
 */
public class DataCenter implements DataSourceBean {

    private Integer id;
    private String url;
    private String username;
    private String password;
    private String driverClassName;
    /**
     * 当前对接程序，外网地址
     */
    private String outerUrl;

    public static DataCenter INSTANCE;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getDriverClassName() {
        return driverClassName;
    }

    public void setDriverClassName(String driverClassName) {
        this.driverClassName = driverClassName;
    }

    @Override
    public String url() {
        return url;
    }

    @Override
    public String username() {
        return username;
    }

    @Override
    public String password() {
        return password;
    }

    @Override
    public String driverClassName() {
        return StringUtils.nvl(driverClassName, "oracle.jdbc.OracleDriver");
    }

    public String getOuterUrl() {
        return outerUrl;
    }

    public void setOuterUrl(String outerUrl) {
        this.outerUrl = outerUrl;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        DataCenter that = (DataCenter) o;
        return Objects.equals(id, that.id) &&
                Objects.equals(url, that.url) &&
                Objects.equals(username, that.username) &&
                Objects.equals(password, that.password) &&
                Objects.equals(driverClassName, that.driverClassName) &&
                Objects.equals(outerUrl, that.outerUrl);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, url, username, password, driverClassName, outerUrl);
    }
}
