package com.jscape.inet.proxy;

import com.jscape.util.SuppressObfuscation;

import static com.jscape.util.Parameters.assertNotNull;

/**
 * @author Alex Usun
 */
@SuppressObfuscation
public class ProxyDescriptor {

    private String host;
    private int port;
    private String username;
    private String password;

    public ProxyDescriptor(String host, int port, String username, String password) {
        assertNotNull(host);
        this.host = host;

        this.port = port;
        this.username = username != null ? username : "";
        this.password = password != null ? password : "";
    }

    public ProxyDescriptor() {
        this("", 0, "", "");
    }
    
    public ProxyDescriptor(ProxyDescriptor that) {
        this(that.host, that.port, that.username, that.password);
    }
    
    public String getHost() {
        return this.host;
    }

    public void setHost(String value) {
        assertNotNull(value);
        this.host = value;
    }

    public int getPort() {
        return this.port;
    }

    public void setPort(int value) {
        this.port = value;
    }

    public String getUsername() {
        return this.username;
    }

    public void setUsername(String value) {
        this.username = value != null ? value : "";
    }

    public String getPassword() {
        return this.password;
    }

    public void setPassword(String value) {
        this.password = value != null ? value : "";
    }

    @Override
    public String toString() {
        return "ProxyDescriptor {"
               + "host='" + this.host + '\''
               + ", port=" + this.port
               + ", username='" + this.username + '\''
               + ", password='*****'"
               + '}';
    }
}
