package com.bocloud.nms.model.hillstone;

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

// RIBV4路由
public class VirtualRouteRibv4Model extends HillStoneGenericModel {
    private Long virtualRouteId; // 所属虚拟路由器id
    private String virtualRouteName; // 所属虚拟路由器
    private Integer routeType; // 路由类别：7->ISP路由；3->目的接口路由；2->目的路由；4->源路由；5->源接口路由；1->就近探测路由；
    private Long destination; // 目的地IP（目的路由、目的接口路由）、源IP（源路由、源接口路由）
    private Long netmask; // 子网掩码
    private Integer nextHopType; // 下一跳类型，3 网关 9 接口，“当前系统虚拟路由器”和“其他系统虚拟路由器”无法测试取值未知
    private Long nextHopId; // 下一跳，取值为接口id，当吓一跳类型为3接口时该字段有效
    private String nextHop; // 下一跳，取值为网关名称或接口名称
    private Long interfaceGate; // 接口网关，当下一跳类型为9接口时该字段有效
    private Integer weight; // 路由权值
    private Integer preference; // 优先权
    private String description; // 描述
    private Long intoInterfaceId; // 入接口id，目的接口路由时该字段有效
    private String intoInterfaceName; // 入接口名称，目的接口路由时该字段有效
    private Long ispId; // ISP信息id，ISP路由时该字段有效
    private String ispName; // ISP信息名称，ISP路由时该字段有效
    private Integer status; // 状态（不太确定）

    public Integer getRouteType() {
        return routeType;
    }

    public void setRouteType(Integer routeType) {
        this.routeType = routeType;
    }

    public Long getDestination() {
        return destination;
    }

    public void setDestination(Long destination) {
        this.destination = destination;
    }

    public Long getNetmask() {
        return netmask;
    }

    public void setNetmask(Long netmask) {
        this.netmask = netmask;
    }

    public Long getInterfaceGate() {
        return interfaceGate;
    }

    public void setInterfaceGate(Long interfaceGate) {
        this.interfaceGate = interfaceGate;
    }

    public Integer getWeight() {
        return weight;
    }

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

    public Integer getPreference() {
        return preference;
    }

    public void setPreference(Integer preference) {
        this.preference = preference;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Long getIntoInterfaceId() {
        return intoInterfaceId;
    }

    public void setIntoInterfaceId(Long intoInterfaceId) {
        this.intoInterfaceId = intoInterfaceId;
    }

    public String getIntoInterfaceName() {
        return intoInterfaceName;
    }

    public void setIntoInterfaceName(String intoInterfaceName) {
        this.intoInterfaceName = intoInterfaceName;
    }

    public String getIspName() {
        return ispName;
    }

    public void setIspName(String ispName) {
        this.ispName = ispName;
    }

    public Long getVirtualRouteId() {
        return virtualRouteId;
    }

    public void setVirtualRouteId(Long virtualRouteId) {
        this.virtualRouteId = virtualRouteId;
    }

    public Integer getNextHopType() {
        return nextHopType;
    }

    public void setNextHopType(Integer nextHopType) {
        this.nextHopType = nextHopType;
    }

    public Long getNextHopId() {
        return nextHopId;
    }

    public void setNextHopId(Long nextHopId) {
        this.nextHopId = nextHopId;
    }

    public String getNextHop() {
        return nextHop;
    }

    public void setNextHop(String nextHop) {
        this.nextHop = nextHop;
    }

    public Long getIspId() {
        return ispId;
    }

    public void setIspId(Long ispId) {
        this.ispId = ispId;
    }

    public String getVirtualRouteName() {
        return virtualRouteName;
    }

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

    public void setVirtualRouteName(String virtualRouteName) {
        this.virtualRouteName = virtualRouteName;
    }

    public Integer getStatus() {
        return status;
    }

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

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        VirtualRouteRibv4Model that = (VirtualRouteRibv4Model) o;
        return Objects.equals(virtualRouteId, that.virtualRouteId) &&
            Objects.equals(routeType, that.routeType) &&
            Objects.equals(destination, that.destination) &&
            Objects.equals(netmask, that.netmask) &&
            Objects.equals(nextHopType, that.nextHopType) &&
            Objects.equals(nextHopId, that.nextHopId) &&
            Objects.equals(interfaceGate, that.interfaceGate) &&
            Objects.equals(intoInterfaceId, that.intoInterfaceId) &&
            Objects.equals(ispId, that.ispId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(virtualRouteId, routeType, destination, netmask, nextHopType, nextHopId, interfaceGate, intoInterfaceId, ispId);
    }
}
