All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aliyun.openservices.ons.api.exactlyonce.datasource.DataSourceConfig Maven / Gradle / Ivy

There is a newer version: 1.9.4.Final
Show newest version
package com.aliyun.openservices.ons.api.exactlyonce.datasource;

import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils;

/**
 * @author gongshi
 */
public class DataSourceConfig implements Comparable {
    private String url = "";
    private String user = "";
    private String passwd = "";
    private String driver = "com.mysql.jdbc.Driver";
    private String productName = "";

    public DataSourceConfig() {
    }

    public DataSourceConfig(String url, String user, String passwd, String driver) {
        this(url, user, passwd, driver, null);
    }

    public DataSourceConfig(String url, String user, String passwd, String driver, String productName) {
        this.url = url;
        this.user = user;
        this.passwd = passwd;
        this.driver = driver;
        this.productName = productName;
    }

    public String getUrl() {
        return url;
    }

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

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getPasswd() {
        return passwd;
    }

    public void setPasswd(String passwd) {
        this.passwd = passwd;
    }

    public String getDriver() {
        return driver;
    }

    public void setDriver(String driver) {
        this.driver = driver;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    @Override
    public String toString() {
        return "DataSourceConfig{" +
                "url='" + url + '\'' +
                ", user='" + user + '\'' +
                ", driver='" + driver + '\'' +
                '}';
    }

    @Override
    public int compareTo(Object o) {
        if (o == null) {
            return -1;
        } else {
            DataSourceConfig configTmp = (DataSourceConfig) o;
            if (configTmp.user.equals(this.user) && configTmp.passwd.equals(this.passwd) && configTmp.url.equals(this.url)
                    && configTmp.driver.equals(this.driver)) {
                return 0;
            } else {
                return StringUtils.compare(this.url, configTmp.url);
            }
        }
    }

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

        DataSourceConfig config = (DataSourceConfig)o;

        if (url != null ? !url.equals(config.url) : config.url != null) { return false; }
        if (user != null ? !user.equals(config.user) : config.user != null) { return false; }
        if (passwd != null ? !passwd.equals(config.passwd) : config.passwd != null) { return false; }
        return driver != null ? driver.equals(config.driver) : config.driver == null;
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy