package com.bocloud.nms.model.hillstone;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

// 监控对象监控的地址
public class MonitorBookIpAddrModel extends HillStoneGenericModel {
    private static final Map<Integer, String> TYPE_MAP = new HashMap<>();

    static {
        TYPE_MAP.put(0, "Ping");
        TYPE_MAP.put(1, "Http");
        TYPE_MAP.put(2, "Arp");
        TYPE_MAP.put(3, "Dns");
        TYPE_MAP.put(4, "Tcp");
    }

    private Long monitorBookId; // 所属监控对象id
    private Integer type; // 类型：0 ping, 1 http, 2 arp, 3 dns, 4 tcp
    private String host; // IP/主机
    private Integer port; // 端口
    private Integer weight; // 权重，默认255
    private Integer threshold; // 重试次数，默认3
    private Integer intervalSecond; // 发送报文间隔，默认3
    private Long sendIntfId; // 发送报文接口id
    private String sendIntf; // 发送报文接口
    private Long recvIntfId; // 接受报文接口id
    private String recvIntf; // 接受报文接口

    public Long getMonitorBookId() {
        return monitorBookId;
    }

    public void setMonitorBookId(Long monitorBookId) {
        this.monitorBookId = monitorBookId;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getHost() {
        return host;
    }

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

    public Integer getPort() {
        return port;
    }

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

    public Integer getWeight() {
        return weight;
    }

    public void setWeight(Integer weight) {
        this.weight = weight;
    }

    public Integer getThreshold() {
        return threshold;
    }

    public void setThreshold(Integer threshold) {
        this.threshold = threshold;
    }

    public Integer getIntervalSecond() {
        return intervalSecond;
    }

    public void setIntervalSecond(Integer intervalSecond) {
        this.intervalSecond = intervalSecond;
    }

    public Long getSendIntfId() {
        return sendIntfId;
    }

    public void setSendIntfId(Long sendIntfId) {
        this.sendIntfId = sendIntfId;
    }

    public String getSendIntf() {
        return sendIntf;
    }

    public void setSendIntf(String sendIntf) {
        this.sendIntf = sendIntf;
    }

    public Long getRecvIntfId() {
        return recvIntfId;
    }

    public void setRecvIntfId(Long recvIntfId) {
        this.recvIntfId = recvIntfId;
    }

    public String getRecvIntf() {
        return recvIntf;
    }

    public void setRecvIntf(String recvIntf) {
        this.recvIntf = recvIntf;
    }

    public String getTypeMap() {
        return TYPE_MAP.get(this.getType());
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        MonitorBookIpAddrModel ipAddr = (MonitorBookIpAddrModel) o;
        return Objects.equals(monitorBookId, ipAddr.monitorBookId) &&
            Objects.equals(type, ipAddr.type) &&
            Objects.equals(host, ipAddr.host) &&
            Objects.equals(port, ipAddr.port);
    }

    @Override
    public int hashCode() {
        return Objects.hash(monitorBookId, type, host, port);
    }
}
