package com.cisdi.data.RFID.gateway;

import com.alibaba.fastjson.JSON;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Rfid server有多个，所以需要支持配置多个服务端地址的
 * @author cup
 * @date 2021/03/03
 */
public class RfidCustomParam implements Serializable {
    private static final long serialVersionUID = -5017472517219960138L;

    /**
     * 每个String 如 192.168.1.5:8823 形式
     */
    private List<String> serverList = new ArrayList<String>();
    
    private Boolean enableHeartbeat = Boolean.FALSE;
    
    private Integer heartbeatTimeInMs = 5000;
    private Integer heartbeatMaxLostCount = 3;

    public List<String> getServerList() {
        return serverList;
    }

    public void setServerList(List<String> serverList) {
        this.serverList = serverList;
    }

    public Boolean getEnableHeartbeat() {
        return enableHeartbeat;
    }

    public void setEnableHeartbeat(Boolean enableHeartbeat) {
        this.enableHeartbeat = enableHeartbeat;
    }

    public Integer getHeartbeatTimeInMs() {
        return heartbeatTimeInMs;
    }

    public void setHeartbeatTimeInMs(Integer heartbeatTimeInMs) {
        this.heartbeatTimeInMs = heartbeatTimeInMs;
    }

    public Integer getHeartbeatMaxLostCount() {
        return heartbeatMaxLostCount;
    }

    public void setHeartbeatMaxLostCount(Integer heartbeatMaxLostCount) {
        this.heartbeatMaxLostCount = heartbeatMaxLostCount;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
    
    public static void main(String[] args){
        RfidCustomParam dto = new RfidCustomParam();
        dto.getServerList().add("192.168.6.55:10000");
        dto.getServerList().add("192.168.6.56:10000");
        dto.getServerList().add("192.165.20.111:10000");
        dto.getServerList().add("192.165.20.112:10000");
        dto.getServerList().add("192.165.20.113:10000");
        dto.getServerList().add("192.165.20.119:10000");
        dto.getServerList().add("192.165.20.118:10000");
        dto.getServerList().add("192.165.20.120:10000");
        dto.getServerList().add("192.165.20.121:10000");
        dto.getServerList().add("192.165.20.121:10000");
        List<String> customParams=dto.getServerList().stream().distinct().collect(Collectors.toList());
        System.out.println(customParams);
        System.out.println(dto);
    }
}
