package com.bocloud.nms.model.hillstone;

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

// VPN IPsec 对端列表
public class VpnIpsecPeerModel extends HillStoneGenericModel {
    private Long vendorId; // 所属平台
    private String name; // 名称
    private Long intfId; // 接口id
    private String intf; // 接口
    private Integer mode; // 认证模式，null 主模式 4 野蛮模式
    private Integer type; // 类型，null 静态IP 2 动态IP 4 用户组
    private Long peer; // 对端IP，当type=null时有效
    private String aaaServer; // AAA服务器，当type=4时有效
    private Integer localIdType; // 本地IP类型，null 无，1 FQDN，2 U-FQDN，5 ASN1-DN 3 KEY_ID 4 IP
    private String localId; // 本地IP
    private Integer peerIdType; // 对端IP类型，null 无，1 FQDN，2 U-FQDN，5 ASN1-DN 3 KEY_ID 4 IP
    private String peerId; // 对端IP
    private Long prop1Id; // 提议1 Id
    private String prop1; // 提议1
    private Long prop2Id; // 提议2 Id
    private String prop2; // 提议2
    private Long prop3Id; // 提议3 Id
    private String prop3; // 提议3
    private Long prop4Id; // 提议4 Id
    private String prop4; // 提议4
    private String preKey; // 共享秘钥
    private String td; // 签名信任域
    private Long tdId; // 签名信任域id

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getIntfId() {
        return intfId;
    }

    public void setIntfId(Long intfId) {
        this.intfId = intfId;
    }

    public String getIntf() {
        return intf;
    }

    public void setIntf(String intf) {
        this.intf = intf;
    }

    public Integer getMode() {
        return mode;
    }

    public void setMode(Integer mode) {
        this.mode = mode;
    }

    public Integer getType() {
        return type;
    }

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

    public Long getPeer() {
        return peer;
    }

    public void setPeer(Long peer) {
        this.peer = peer;
    }

    public String getAaaServer() {
        return aaaServer;
    }

    public void setAaaServer(String aaaServer) {
        this.aaaServer = aaaServer;
    }

    public Integer getLocalIdType() {
        return localIdType;
    }

    public void setLocalIdType(Integer localIdType) {
        this.localIdType = localIdType;
    }

    public String getLocalId() {
        return localId;
    }

    public void setLocalId(String localId) {
        this.localId = localId;
    }

    public Integer getPeerIdType() {
        return peerIdType;
    }

    public void setPeerIdType(Integer peerIdType) {
        this.peerIdType = peerIdType;
    }

    public String getPeerId() {
        return peerId;
    }

    public void setPeerId(String peerId) {
        this.peerId = peerId;
    }

    public String getProp1() {
        return prop1;
    }

    public void setProp1(String prop1) {
        this.prop1 = prop1;
    }

    public String getProp2() {
        return prop2;
    }

    public void setProp2(String prop2) {
        this.prop2 = prop2;
    }

    public String getProp3() {
        return prop3;
    }

    public void setProp3(String prop3) {
        this.prop3 = prop3;
    }

    public String getProp4() {
        return prop4;
    }

    public void setProp4(String prop4) {
        this.prop4 = prop4;
    }

    public String getPreKey() {
        return preKey;
    }

    public void setPreKey(String preKey) {
        this.preKey = preKey;
    }

    public String getTd() {
        return td;
    }

    public void setTd(String td) {
        this.td = td;
    }

    public Long getTdId() {
        return tdId;
    }

    public void setTdId(Long tdId) {
        this.tdId = tdId;
    }

    public Long getProp1Id() {
        return prop1Id;
    }

    public void setProp1Id(Long prop1Id) {
        this.prop1Id = prop1Id;
    }

    public Long getProp2Id() {
        return prop2Id;
    }

    public void setProp2Id(Long prop2Id) {
        this.prop2Id = prop2Id;
    }

    public Long getProp3Id() {
        return prop3Id;
    }

    public void setProp3Id(Long prop3Id) {
        this.prop3Id = prop3Id;
    }

    public Long getProp4Id() {
        return prop4Id;
    }

    public void setProp4Id(Long prop4Id) {
        this.prop4Id = prop4Id;
    }

    public Long getVendorId() {
        return vendorId;
    }

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

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

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        VpnIpsecPeerModel that = (VpnIpsecPeerModel) o;
        return Objects.equals(vendorId, that.vendorId) &&
            Objects.equals(name, that.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(vendorId, name);
    }
}
