package com.bocloud.nms.model.hillstone;

import java.util.Objects;
import java.util.Optional;

// SLB服务器状态
public class SLBServiceTypeModel extends HillStoneGenericModel {
    private Long vendorId; // 所属平台
    private Long virtualRouterId; // 所属虚拟路由器id
    private String virtualRouter; // 所属虚拟路由器
    private Long ip; // 服务器IP地址
    private String port; // 端口
    private String status; // 状态
    private Integer currConnection; // 当前连接数
    private Integer haGroup; // HA组
    private Long destNatId; // 目的NAT的id
    private Long destNatRuleId; // 目的NAT的ruleId

    public Long getVendorId() {
        return vendorId;
    }

    public void setVendorId(Long vendorId) {
        this.vendorId = vendorId;
    }

    public Long getIp() {
        return ip;
    }

    public void setIp(Long ip) {
        this.ip = ip;
    }

    public String getVirtualRouter() {
        return virtualRouter;
    }

    public void setVirtualRouter(String virtualRouter) {
        this.virtualRouter = virtualRouter;
    }

    public String getPort() {
        return port;
    }

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

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Long getVirtualRouterId() {
        return virtualRouterId;
    }

    public void setVirtualRouterId(Long virtualRouterId) {
        this.virtualRouterId = virtualRouterId;
    }

    public Integer getCurrConnection() {
        return currConnection;
    }

    public void setCurrConnection(Integer currConnection) {
        this.currConnection = currConnection;
    }

    public Integer getHaGroup() {
        return haGroup;
    }

    public void setHaGroup(Integer haGroup) {
        this.haGroup = haGroup;
    }

    public Long getDestNatRuleId() {
        return destNatRuleId;
    }

    public void setDestNatRuleId(Long destNatRuleId) {
        this.destNatRuleId = destNatRuleId;
    }

    public Long getDestNatId() {
        return destNatId;
    }

    public String getIpString() {
        return Optional.ofNullable(this.getIp()).map(Ipv4::convertIp).orElse(null);
    }

    public void setDestNatId(Long destNatId) {
        this.destNatId = destNatId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        SLBServiceTypeModel that = (SLBServiceTypeModel) o;
        return Objects.equals(virtualRouterId, that.virtualRouterId) &&
            Objects.equals(ip, that.ip) &&
            Objects.equals(port, that.port);
    }

    @Override
    public int hashCode() {
        return Objects.hash(virtualRouterId, ip, port);
    }
}
