package com.lanyuanxiaoyao.service.cli.runner;

import com.lanyuanxiaoyao.service.cli.core.HostInfo;

/**
 * 增补HostInfo属性
 *
 * @author lanyuanxiaoyao
 * @date 2024-02-25
 */
public class HostInfoWrapper {
    private final HostInfo hostInfo;

    private final String host;

    public HostInfoWrapper(String host, HostInfo hostInfo) {
        this.host = host;
        this.hostInfo = hostInfo;
    }

    public String getHost() {
        return host;
    }

    public String getIp() {
        return hostInfo.getIp();
    }

    public Boolean getUseAuthority() {
        return hostInfo.getUseAuthority();
    }

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

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

    public HostnameIp getHostnameIp() {
        return new HostnameIp(getHost(), getIp());
    }

    @Override
    public String toString() {
        return "HostInfoWrapper{" +
               "hostInfo=" + hostInfo +
               ", host='" + host + '\'' +
               '}';
    }

    public static class HostnameIp {
        private final String hostname;
        private final String ip;

        private HostnameIp(String hostname, String ip) {
            this.hostname = hostname;
            this.ip = ip;
        }

        public String getHostname() {
            return hostname;
        }

        public String getIp() {
            return ip;
        }

        @Override
        public String toString() {
            return "HostnameIp{" +
                   "hostname='" + hostname + '\'' +
                   ", ip='" + ip + '\'' +
                   '}';
        }
    }
}
